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

Most upvoted comments

👍

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?