Podman Notes
|
All Container related commands can be found here. |
1. Podman Installation
1.1. RHEL
-
Install with:
sudo dnf install -y podman podman-compose -
Enable:
systemctl --user enable --now podman.socket-
Install guide is here.
-
1.2. Ubuntu
|
Do not install on Ubuntu until a solution is found for podman-compose! |
1.2.1. Podman-compose Installation on Ubuntu
|
The official podman-compose package available in the official repositories is outdated! Do not execute the following command:
|
-
First install pip
sudo apt install -y python3-pip -
Install
podman-composepip install podman-compose --break-system-packages -
Update path
export PATH="$HOME/.local/bin:$PATH"
1.2.2. Podman Installation on Ubuntu
|
The official podman package available in the official repositories is outdated! Do not execute the following two commands:
Instead, follow the instructions below: |
-
First install Homebrew.
-
Now install via
Homebrew:brew install podman -
To start podman now and restart at login:
brew services start podman -
Install
newuidmapandnewgidmap(from the uidmap package) to map user/group IDssudo apt install -y uidmap -
Make
podmanexecutablechmod +x $(which podman)
2. Podman Container Commands
|
All commands can be found here. |
3. Updating a Pod
-
The following will update all containers within a Pod
-
cd into the project folder containing the Pod’s
compose.yamlfileExamplecd /home/repo-pod-master/pod-ai -
Pull the latest Pod images
Execute thepullcommandpodman-compose pull -
Recreate the Pod
Force recreatepodman-compose up -d --force-recreate -
Prune any dangling images
This will delete any images that are not currently in use Force recreatepodman image prune
-
4. Podman-Compose Commands
4.2. Podman-Compose systemd Commands (RHEL)
4.2.1. Initialization
-
On RHEL systems,
Podsdo not start on their own when the system is rebooted.
This can be fixed withsystemdintegration which will allow Pods to be turned into services and controlled by the systemctl commands.
| Only do these steps once. |
-
First, turn on the
container_manage_cgroupboolean to run containers with systemd:sudo setsebool -P container_manage_cgroup on -
Create the
systemdunit template file entry with:sudo podman-compose systemd -a create-unit -
Confirm creation of the template:
Runcat /etc/systemd/user/podman-compose@.serviceExpand for sample result
[Unit] Description=%i rootless pod (podman-compose) [Service] Type=simple EnvironmentFile=%h/.config/containers/compose/projects/%i.env ExecStartPre=-/usr/bin/podman-compose up --no-start ExecStartPre=/usr/bin/podman pod start pod_%i ExecStart=/usr/bin/podman-compose wait ExecStop=/usr/bin/podman pod stop pod_%i [Install] WantedBy=default.target -
For all users that will run pods.
-
Enable linger
This will allow containers to continue to run even if the user is logged out.sudo loginctl enable-linger 'mattosd' -
In the user’s home dir, run
restorecon -R
-
4.2.2. Create SystemD Commands
-
For each container:
The following will only work if the pod has run at least once via
podman-compose up -d-
cd into the project folder containing the Pod’s
compose.yamlfile -
Shutdown the pod if it’s already running
podman-compose down -
Register Unit File
podman-compose systemd -a register -
Enable and Start up the Pod
systemctl --user enable --now 'podman-compose@<pod name>'Examplesystemctl --user enable --now 'podman-compose@pod-ai' -
Now you can use
systemdcommands to stop, start, and get the status of the pod container:Start Examplesystemctl --user start 'podman-compose@pod-ai'Status Examplesystemctl --user status 'podman-compose@pod-ai'Stop Examplesystemctl --user stop 'podman-compose@pod-ai'
-
4.2.3. Remove SystemD Commands
-
cd into the project folder containing the Pod’s
compose.yamlfile -
Stop the service.
Examplesystemctl --user stop podman-compose@pod-uac-server.service -
Disable the service.
Examplesystemctl --user disable podman-compose@pod-uac-server.service -
Restart the systemd daemon.
Examplesystemctl --user daemon-reload