-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Containers with --restart=always
policy does not restart services automatically after system reboot.
#10539
Comments
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. |
@vrothberg That bug is private, though? Might be better to keep this open for public discussion. |
Good catch, thanks, @mheon. Reopened. |
FWIW, I think we could tackle it via systemd unit that fires off at boot and runs a |
Yes I thought this was something @boaz0 was working on, I believe we have all of the parts and now we just need to add a systemd unit file to run at boot time to start the |
@rhatdan that's correct. This is the PR you're talking about. @amtdas Let me know if it is working for you. If not, I will fix this. |
@boaz0 @rhatdan, I think we should create a |
@vrothberg - sounds like a good idea. Can you assign this task to me? |
Done, thank you! |
Above was mistakenly closed, reopening it. |
Sorry for commenting on closed issue but is the intent that this goes out with v3.3 or will this be backported? If v3.3, is there any estimate when that will be? This feature is a real quality-of-life enhancer for running Podman server processes. |
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. |
We could do so, but we'd need to add a new filter that detects stopped-by-user containers. |
Visible with |
That's not intended behavior, that's a pretty significant bug - the cleanup process is not running on manually-stopped containers and they may not be unmounted. |
What do you mean by "cleanup process"? The equivalent of |
It can handle |
So, you are saying that |
Yes. We do retain an internal state which indicates whether a container was manually stopped by the user ( |
In case that thing you discussed was a bug, how about creating separate issue about it? |
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 systemctl enable podman-restart |
For rootless containers you may also try (no root/sudo command!): |
This solution seems rather interesting, however, I am curios what steps would be needed in pursuance of also making inclusive a "restart-policy=unless-stopped". For example, sometimes I wish to stop a container and do not wish it to automatically restart. However, if it comes to pass that the Fedora CoreOS instance reboots then yes, I'd surely wish it to automatically restart. I would suggest simply adding ',restart-policy=unless-stopped' or perhaps instituting some sort of configuration file for the service that could be most easily amended when the need arises. What say you? Stuart, N3GWG |
Thanks for reaching out, @n3gwg! The idea sounds interesting and I understand its value. Would you open a new issue for that? This way, we can better track work on it. |
Done. |
Hello with podman version 4.3.1 and podman-compose version 1.0.3, my container is not restarting while using:
I'm currently on Debian 12 Bookworm, I attempted with |
@gloatoriginal, thanks for reaching out. Please create a new issue and provide all the data request in the issue template. This one here is old and has already been closed. The new issue will help up track things down and triage them individually. |
Also could you try ths with podman 4.4+ version. |
Based on this tutorial I have created a bash script to automate the whole process of Creating a systemd service as non-root user. Make sure to pass CONTAINER_NAME and IMAGE_NAME as arguments..
Save the script to a file, for example, podman_systemd_setup.sh, and give it execute permissions using chmod +x podman_systemd_setup.sh. Finally, run the script using ./podman_systemd_setup.sh. This script will create the container, generate a systemd unit file, move it to the appropriate location for a non-root user, and enable the systemd service. Here's also a simple wrapper script that checks for the --restart always flag, and if present, it runs the provided podman_systemd_setup.sh script after executing the original Podman command:
Save this script as podman_wrapper.sh, and give it execute permissions using chmod +x podman_wrapper.sh. Update the SYSTEMD_SETUP_SCRIPT variable with the correct path to your podman_systemd_setup.sh script. To use this wrapper script instead of the original Podman command, you can create an alias in your shell configuration file (e.g., ~/.bashrc or ~/.zshrc): Replace /path/to/podman_wrapper.sh with the actual path to the podman_wrapper.sh script. Then, restart your terminal or run source ~/.bashrc (or source ~/.zshrc) to apply the changes. Now, when you run a podman run command with the --restart always flag, the wrapper script will call the original Podman command and then execute the podman_systemd_setup.sh script if the flag is present. |
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:
--restart=always
policyDescribe 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 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
},
The text was updated successfully, but these errors were encountered: