moby: Manually stopped containers should not start after daemon restart
Container with a restart policy (eg --restart always
) is always restarted on daemon restart, even if the container has already been put to the stopped state manually.
Background: when I update containers I’d like to keep old containers around for a while in order to do a rollback if needed. Now, should the daemon restart, all versions of the containers start again.
> docker run -d --restart always --name r0 busybox sleep 1000
> docker stop r0
> docker ps | grep r0 | wc -l
0
> sudo service docker restart
> docker ps | grep r0 | wc -l
1
Tested with v1.4.1
and v1.5.0
.
I could help out fixing this if it gets confirmed as a bug.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 32 (20 by maintainers)
Commits related to this issue
- Don’t restart stopped containers on boot. Fix #11008 Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> — committed to tonistiigi/docker by tonistiigi 9 years ago
- Add unless-stopped restart policy Fixes #11008 Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> — committed to tonistiigi/docker by tonistiigi 9 years ago
- Fix docs for "unless-stopped" restart policy This part: >or Docker itself is stopped or restarted. is not accurate. When you restart docker daemon containers with "unless-stopped" policy are also r... — committed to adw1n/docker.github.io by adw1n 6 years ago
👍
I keep old app containers for a short period of time after deploying the new one, so that if something is broken I can simply restart one of them. When the server restarts, in my case CoreOS does it every once in a while when gets automatically updated, I get tens of containers running simultaneously while I need only one that wasn’t manually stopped. I’d assume I’m not the only one doing this?