How to prevent docker from starting a container automatically on system startup? [duplicate]

Docker starts a container on every system startup (debian) but I didn't create a service to do so. How can I prevent docker from doing that?


Solution 1:

Docker will autostart any container with a RestartPolicy of 'always' when the docker service initially starts. You won't find any evidence of this within cron or any other normal system startup scripts; you'll have to dig into the container configuration to find it.

docker inspect my-container (Look for RestartPolicy in the output)

I've mostly had this situation occur when a container was created with --restart always, and the situation later changed such that I no longer wanted this to happen.

After docker 1.11, this is easy to fix

docker update --restart=no my-container

Original answer is here: docker - how do you disable auto-restart on a container?

Solution 2:

The info is in /var/lib/docker/containers/<hash>/hostconfig.json (having root permissions)

check for RestartPolicy.Name = "always" in any of those files.