Please find the steps below for enabling the podman container instance to auto restart when the OS is rebooted.
1) list the podman instances to get the container ID and name.
podman ps -a
For e.g. below output
# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45782651b66d localhost/ock-ostree:latest nginx -g daemon o... 2 minutes ago Up 2 minutes 0.0.0.0:8080->80/tcp ock-content-server
2) Configure the podman container instance as service and enable the service.
For this use below steps.
2(a) Create systemd file for podman container instances. In below command replace the name with container ID and os-tree-podman.service with the service name of choice.
podman generate systemd --new --name 9596fff2a7b1>/etc/systemd/system/ostree-podman.service
Above command will create a file /etc/systemd/system/ostree-podman.service
2(b) Restart the system daemon
systemctl daemon-reload
2(c) Enable the newly created podman container system unit file.
systemctl enable ostree-podman.service
2(d) List the system unit files
systemctl list-unit-files | grep -i podman
You should see the newly created podman container system unit file and it should be enabled. For e.g. below output
# systemctl list-unit-files | grep -i podman
ostree-podman.service enabled
3) Reboot the host and validate that the podman container instances is auto restarted.
For veirfying this, run below command.
podman ps -a
Keywords
Configuring setting up setup autorestart auto-restart service unit files files containers instances operating system rebooting reboots reboot restart restarting restarts os
No comments:
Post a Comment