/kind bug
Description
Installing _podman-docker_ the CLI command _podman_ should be as compatible as possible w/ docker.
There is an important docker command that is used in many dockerized systems. B/c the compatibility is not perfect in the podman command all the scripts should be changed because of podman. In practice you need an IF clause in all your scripts to check if you are running the script in a podman or a docker system, and it is not the right way in the long run.
In the Docker, you have to use _docker run --–restart=unless-stopped_ e.g for testing and sometimes in a production environment. This way you may stop a container and it does not start after reboot, like the _docker run --–restart=always_ does in Docker!
But _podman run --restart=unless-stopped_ gives an error b/c this is not supported in the _libpod_.
And if you change your Docker scripts to _docker run -–restart=always_ you will lose the function you need, namely, keeping container stopped after reboot! Of course, it works in _podmad_ but not in the Docker!
Steps to reproduce the issue:
Install _podman-docker_ and a native _docker_
Run this command in the both docker and podman environments:
$ _docker run --restart=unless-stopped_
Describe the results you received:
podman fails to an error
Describe the results you expected:
podman should not fail
Additional information you deem important (e.g. issue happens only occasionally):
Correction: accept _--restart=unless-stopped_ using the policy _unless-stopped_ as a synonym to the policy _always_ in the podman/libpod.
We cannot support '--unless-stopped' as it implies the container will be
restarted after a reboot, but Podman cannot do this. Docker has a daemon
that starts on boot and it uses this to start containers on boot; Podman
does not have a daemon and this cannot do the same. This limitation is
documented in the manpages.
We recommend using Systemd unit files from 'podman generate systemd' if you
wish to autostart containers on boot.
On Sat, Jun 6, 2020, 05:38 Harri Luuppala notifications@github.com wrote:
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Installing podman-docker the podman should be as compatible w/ docker as
possible. There is an important docker command that is in many dockerized
systems. B/c this compatibility is not in podman the scripts should be
charged for podman. In practice you need an IF clause in all scripts to
check if you run in podman or docker and it is frustrating in long run.In Docker you have to use "docker run --–restart=unless-stopped" e.g in
some testings and production environments. This way you may stop a
container and it does not start after reboot, like the "docker run
--–restart=always" does!But "podman run --–restart=unless-stopped" gives and error b/c this is not
supported in libpod.If you change your Docker scripts to "docker run --–restart=always" you
lose the function you need! Of course it works in podmad but not in Docker!Steps to reproduce the issue:
1.
Install podman-docker and a native docker
2.Run command in both docker and podman environment:
$ docker run --–restart=unless-stopped inDescribe the results you received:
podman fails to an errorDescribe the results you expected:
podman should not failAdditional information you deem important (e.g. issue happens only
occasionally):
Correction: accept "--restart=unless-stopped" using the policy
"unless-stopped" as a synonym to the policy "always"in podman/libpod.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/containers/libpod/issues/6508, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB3AOCASH6TG2DENOXRKJILRVIFBJANCNFSM4NVZXFCA
.
@mheon Crazy idea of the day. Why don't we just add a unit file to run podman on boot and have it check to see if any containers needed to be started, then start them. Would give us the same functionality as Docker without having to have a daemon.
@rhatdan what state would a container need to be in for an autorestart? Running? I'd just be concerned that there might be a container that could get into some ugly state if the system went down before it completed its task.
Could we add a 'restartable' field to the container to allow the user to decide which containers to restart if necessary? Maybe add a --restart option to the run command that would let it auto-start on reboot?
@rhatdan Hm. We could probably do this with a oneshot unit - have a podman system on-boot that starts anything we intend to be running. I need to double-check to be sure, but I think the current restart policy code will probably allow you to determine what containers need to be restarted without much trouble?
Hello from Finland,
I was not clear and detailed enough. Let's try again :-)
And sorry this lengthy text...
The issue is that podman run command breaks to an errno/error b/c of compatibility issue that the podman-docker/podman/libpod is missing one argument/policy needed for compatibility. This has nothing to do with the answers you kindly already provided, but misunderstanding how unless-stopped works.
@mheon wrote: We cannot support '--unless-stopped' as it implies the container will be
restarted after a reboot, but Podman cannot do this.
_Comment:_ It is opposite! And that is a common mistake. Unless-stopped means that container does _not start_ after a reboot!! See: https://docs.docker.com/config/containers/start-containers-automatically/
@rhatdan Systemd...
_Comment:_ It is an excellent idea and probably will be welcomed by other users. But it is not needed for this fix. [ I may handle systemd Units :-) ] .
My issue is before the reboot, not after.
The issue is that the podman run breaks. There is an argument --restart=unless-stropped that is missing. The unless-stopped does mean that a stopped container stays stopped after a reboot!
Note: This is not fixing this issue I am describing below, but emphasized that compatibility is needed. This one here is for systemd only, and is fixing the compatibility issue after rebooting! But this is related to my request which is before rebooting and in the podman run!
0.1 OpenStack issue and fix
https://opendev.org/openstack/paunch/commit/6a6f99b724d45c3d2b429123de178ca2592170f0
0.2 SystemD doesn't have the equivalent of docker unless-stopped.
Let's force 'always' so containers aren't restarted when stopped by
systemd, but restarted when in failure. Also this code is only for
podman now, so nothing changed for Docker deployments.
if restart == 'unless-stopped':
restart = 'always'
Definitions
used later on to describe the issue
Docker
According to the Docker manual:
"_unless-stopped_ Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts."
Note: Read this carefully again!
Podman
Podman is programmed wrongly.
To be precise:
Implement PU as a synonym to PA. So that they are the same commands!
To be precise:
Steps to reproduce the issue:
Describe the results you received:
podman fails to an error
docker works OK
Describe the results you expected:
podman should not fail
Additional information you deem important (e.g. issue happens only occasionally):
Summary:
This is not related to the "missing" Docker Engine - it is not the issue,
nor anything to do with restarting after a reboot - it is not the issue,
but just to make sure that podman run * is compatible to *docker run
_docker run --restart=unless-stopped_ so that
_podman run --restart=unless-stopped_ does not break to an error.
/Harri
Hm. So unless-stopped works exactly like always, minus the feature we don't support yet? That should be an easy fix. Thanks for explaining!
Unless-stopped means that container does not start after a reboot!!
This is not correct. unless-stopped starts containers even after reboot if you're talking about docker.
Well, it's somewhat academic since Podman itself cannot handle restarting after a reboot now; we recommend managing your containers with systemd unit files to achieve that.