Outils pour utilisateurs

Outils du site


tech:notes_podman

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:notes_podman [2025/10/03 10:16] Jean-Baptistetech:notes_podman [2026/03/23 10:20] (Version actuelle) Jean-Baptiste
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Podman Docker}}
 +
 +# Notes Podman
 +
 +Voir aussi :
 +* Apptainer/Singularity
 +
 +Voir :
 +* https://indico.cern.ch/event/757415/contributions/3421994/attachments/1855302/3047064/Podman_Rootless_Containers.pdf
 +* https://github.com/containers/podman/blob/main/troubleshooting.md#5-rootless-containers-cannot-ping-hosts
 +* https://blog.stephane-robert.info/docs/conteneurs/moteurs-conteneurs/podman/
 +* https://github.com/containers/podman/blob/main/docs/tutorials/basic_networking.md
 +* https://www.n0tes.fr/categories/Conteneurisation/Podman/
 +* https://docs.oracle.com/en/operating-systems/oracle-linux/podman/podman-ConfiguringNetworkingforPodman.html#configuring-podman-networking
 +* https://serverfault.com/questions/1131478/how-to-configure-a-podman-container-to-let-it-communicate-with-the-host-as-well
 +* https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/building_running_and_managing_containers/assembly_managing-a-container-network_building-running-and-managing-containers#proc_connecting-a-container-to-a-network_assembly_managing-a-container-network
 +* ''/etc/containers/''
 +* https://www.devoteam.com/fr/expert-view/la-migration-vers-podman-est-elle-la-solution-pour-se-passer-de-docker/
 +* https://medium.com/@gabrielgbs/rootless-podman-restart-rootless-containers-on-boot-eab354eae487
 +* https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/building_running_and_managing_containers/assembly_porting-containers-to-systemd-using-podman_building-running-and-managing-containers#assembly_porting-containers-to-systemd-using-podman_building-running-and-managing-containers
 +* https://www.redhat.com/en/blog/container-systemd-persist-reboot
 +* https://fr.linux-console.net/?p=7480
 +* https://www.redhat.com/en/blog/container-networking-podman
 +* https://docs.portainer.io/2.22/start/install-ce/server/podman/linux
 +* https://hpc.llnl.gov/documentation/user-guides/using-containers-lc-hpc-systems/containers-troubleshooting
 +
 +Rootless : https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md
 +
 +
 +Volumes / Stockage / Storage : 
 +* NFS : https://oneuptime.com/blog/post/2026-03-17-mount-nfs-shares-volumes-podman/view
 +
 +
 +
 +Installez slirp4netns (va être remplacé par **pasta** à partir de Podman 5)
 +~~~bash
 +apt-get install slirp4netns
 +~~~
 +
 +Ensuite, configurez une quantité d'espaces de noms réseau définis par l'utilisateur :
 +
 +~~~bash
 +echo "user.max_user_namespaces=28633" > /etc/sysctl.d/userns.conf
 +sysctl -p /etc/sysctl.d/userns.conf
 +~~~
 +
 +Cette commande permet d'utiliser les espaces de noms réseau sans être root.
 +
 +
 +## Démarrage automatique
 +
 +~~~bash
 +systemctl --user enable --now podman-restart
 +~~~
 +
 +
 +## Conf registry
 +
 +''/etc/containers/registries.conf''
 +~~~ini
 +[registries.search]
 +registries = ['docker.io', 'quay.io', 'ghcr.io']
 +
 +[registries.insecure]
 +registries = []
 +~~~
 +
 +
 +## Exemple
 +
 +
 +~~~bash
 +podman build -t jibe/dokuwiki --build-arg http_proxy="$http_proxy" --build-arg https_proxy="$https_proxy" -f Containerfile .
 +
 +podman run -a stdout --rm --name=dokuwiki1 -v $PWD/tmp/dokuwiki/data/:/var/www/wiki/www/data -v $PWD/tmp/dokuwiki/conf/:/var/www/wiki/www/conf -m 512m -p 8082:8080 jibe/dokuwiki
 +~~~
 +
 +
 +Contener - entrypoint
 +~~~
 +$ podman run --entrypoint /usr/bin/echo -ti --rm debian -e 'Test1\nTest2'
 +Test1
 +Test2
 +~~~
 +
 +
 +~~~bash
 +#podman generate systemd --restart-policy=always -t 1 dokuwiki1
 +#podman generate systemd --restart=always -t 1 dokuwiki1
 +
 +# podman generate systemd --new --files --name httpd
 +# quadlet ?
 +~~~
 +
 +
 +Autre
 +~~~bash
 +echo 1 > /proc/sys/kernel/unprivileged_userns_clone
 +~~~
 +
 +
 +## Conf UIDMAP
 +
 +Voir `/proc/sys/user/max_user_namespaces`
 +
 +| Colonne | Description                                                   |
 +| ------- | ------------------------------------------------------------- |
 +|       1 | Nom de l'utilisateur système sur le hôte                      |
 +|       2 | Numéro d'UID sur le hôte correspondant à l'UID 0 du NS        |
 +|       3 | Plage; notre d'UID à l'intérieur du NS                        |
 +
 +
 +~~~bash
 +sudo usermod --add-subuids 10000-75535 USERNAME
 +sudo usermod --add-subgids 10000-75535 USERNAME
 +~~~
 +
 +
 +''/etc/subuid''
 +~~~
 +jean:100000:65536
 +test:165536:65536
 +plop:231072:65536
 +k8s:296608:65536
 +~~~
 +
 +''/etc/subgid''
 +~~~
 +jean:100000:65536
 +test:165536:65536
 +plop:231072:65536
 +k8s:296608:65536
 +~~~
 +
 +
 +## Commandes utiles
 +
 +Afficher tous les mappages de ports de conteneur utilisés
 +~~~bash
 +podman port -a
 +~~~
 +
 +Pour un container particulier
 +~~~bash
 +podman port ctn-app1
 +~~~
 +
 +
 +
 +## Réseau
 +
 +Podman prend en charge 2 réseaux backend pour les conteneurs : Netavark et CNI.
 +
 +Pour vérifier quel backend réseau est utilisé :
 +
 +~~~
 +$ podman info --format {{.Host.NetworkBackend}}
 +netavark
 +~~~
 +
 +Pour modifier le backend réseau, définissez la configuration dans ''/usr/share/containers/containers.conf'' :
 +
 +~~~
 +[network]
 +[...]
 +# Network backend determines what network driver will be used to set up and tear down container networks.
 +# Valid values are "cni" and "netavark".
 +network_backend = "netavark"
 +~~~
 +
 +
 +La commande podman network create créer un réseau compatible DNS.
 +
 +Création d’un réseau appelé db_network en spécifiant le sous-réseau 10.87.0.0/24 et la passerelle 10.87.0.1 :
 +
 +~~~
 +podman network create --gateway 10.87.0.1 --subnet 10.87.0.0/24 db_network
 +~~~
 +
 +
 +La commande ''podman network inspect'' affiche les informations sur un réseau spécifique 
 +
 +
 +
 +La commande ''podman run --network'' permet d’ajouter le réseau DNS db_network à un nouveau conteneur
 +
 +
 +
 +Re appliquer les règles réseau Podman
 +~~~bash
 +podman network reload 
 +~~~
 +
 +Avant cette commande il faillait faire un restart des containers.
 +
 +
 +A common problem is that reloading the firewall deletes the netavark iptables rules resulting in a loss of network connectivity for rootful containers.
 +
 +
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki