podman: Containers with `--restart=always` policy does not restart services automatically after system reboot.

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description Containers with --restart=always policy does not cause services to automatically restart after the system reboot, as it does with Docker.

Steps to reproduce the issue:

  1. Create a new container with --restart=always policy
podman run -d --name test-rh83 -p 80:80 --restart=always docker.io/httpd
Trying to pull docker.io/httpd...

podman ps -a
CONTAINER ID  IMAGE                           COMMAND           CREATED             STATUS                 PORTS               NAMES
da1ce8f0ec32  docker.io/library/httpd:latest  httpd-foreground  About a minute ago  Up About a minute ago  0.0.0.0:80->80/tcp  test-rh83
  1. Reboot or restart the system/kernel
  2. Containers shows in Exited state after system reboot and need automatic start.
podman ps -a
CONTAINER ID  IMAGE                           COMMAND           CREATED         STATUS                         PORTS               NAMES
da1ce8f0ec32  docker.io/library/httpd:latest  httpd-foreground  26 minutes ago  Exited (0) About a minute ago  0.0.0.0:80->80/tcp  test-rh83

Describe the results you received: Podman don’t restart containers after system reboot which were in running state whereas docker does support this after applying --restart=always policy .

Describe the results you expected: I understand that podman is daemonless and rely completely on systemd for system integration. Having this feature in podman in future release will remove systemd dependency.

Additional information you deem important (e.g. issue happens only occasionally):

podman version
Version:      3.0.2-dev
API Version:  3.0.0
Go Version:   go1.15.7
Built:        Wed Apr  7 18:36:54 2021
OS/Arch:      linux/amd64

podman inspect test-rh83 [ { “Id”: “da1ce8f0ec325a74fe516251c6a5d906fa364e95ad003ff8c1cd51627bb30739”, “Created”: “2021-06-01T16:16:00.64145968+10:00”, “Path”: “httpd-foreground”, “Args”: [ “httpd-foreground” ], “State”: { “OciVersion”: “1.0.1-dev”, “Status”: “exited”, “Running”: false, “Paused”: false, “Restarting”: false, :::::::::::::::::::::::: }, “RestartPolicy”: { “Name”: “always”, “MaximumRetryCount”: 0 },

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 31 (16 by maintainers)

Most upvoted comments

@vrothberg That bug is private, though? Might be better to keep this open for public discussion.

@lsm5 PTAL, I don’t think it is enabled by default even now in podman 4.3. I agree that we should enable this by default. @lsm5 WDYT?

This is a new feature so it will not be backported. I expect 3.3 to land late this month or early next month.

Sorry for commenting on closed issue, but have you considered to support also the --restart=unless-stopped policy at the same time? The filter should be set-up so that it considers all restart-policy=always containers that are not in RUNNING state (which typically are not at boot time) and also all restart-policy=unless-stopped containers that are not in RUNNING or STOPPED state. When you reboot a machine they typically end up in EXITED state.

@vrothberg - sounds like a good idea. Can you assign this task to me?

Done, thank you!

@boaz0 @rhatdan, I think we should create a podman-restart.service in https://github.com/containers/podman/tree/master/contrib/systemd/system. This way, it can be installed (and enabled) by packages. What do you think?

@rhatdan that’s correct. This is the PR you’re talking about. @amtdas as @vrothberg mentioned: creating a systemd unit files that runs podman start --filter restart-policy=always --all will resolve your issue.

@amtdas Let me know if it is working for you. If not, I will fix this. Thanks.

Thanks for opening the issue. Since there’s already an RFE in the Red Hat Bugzilla [1], I think we should keep the discussion there.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1967421

for the record, with podman-3.4.7 vanilla-installed on fedora 35, I had to manually enable the systemd service, this is not done automatically by rpm install as I thought at first

systemctl enable podman-restart

For rootless containers you may also try (no root/sudo command!): systemctl --user enable podman-restart System unit did not work for me