Is there a possibility to change restart policy of podman container?

Viewed 3408

Is there a possibility to change container restart policy using podman? We can set policy during creating container podman run --restart always, but how to change it when the container is created?

Using docker we have docker update command which allows us to do so. Unfortunately there is no podman update command. Can it be done? Or do I need to create a new container?

1 Answers

when using podman you should create a systemd service that will manage podman container.

  1. create systemd file "/etc/systemd/system/containername.service"
[Unit]
Description=your container

[Service]
Restart=always
ExecStart=/usr/bin/podman start -a containername
ExecStop=/usr/bin/podman stop -t 2 containername

[Install]
WantedBy=local.target
  1. run command:

systemctl daemon-reload

  1. enable service to start at boot

systemctl enable containername.service

  1. restart service

systemctl restart containername.service

You can also add some other restart systemd parameters like:

RestartSec (Configures the time to sleep before restarting a service), StartLimitInterval (seconds service is it not permitted to start any more),  StartLimitBurst

for more details check man pages: "man systemd.service"

Related