Kanciarzek
Kanciarzek

Reputation: 119

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

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?

Upvotes: 9

Views: 9275

Answers (2)

Mladen B.
Mladen B.

Reputation: 3013

podman update --restart=always <container-id>

available in podman update since v 5.1.0

Upvotes: 0

Gaga Samushia
Gaga Samushia

Reputation: 155

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"

Upvotes: 3

Related Questions