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

DockerStartup

Docker Problem Overview


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?

Docker Solutions


Solution 1 - Docker

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: https://stackoverflow.com/questions/37599128/docker-how-do-you-disable-auto-restart-on-a-container

Solution 2 - Docker

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

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

Solution 3 - Docker

  1. You can also take a look in System->Preferences->Startup Applications. (Search startup application app)

  2. use this command : 'Crontab -l' (check any cronjob is set or not)

  3. grep docker in /etc/init.d and if you find you can remove from there with sudo permission ( Make sure you dont change other files or anything else, do it on your risk )

  4. sudo docker run --restart=no redis (replace redis with your container name)

Let me know if you still find any problem.

Solution 4 - Docker

Launch Docker if not running. Click the Docker icon in the menu bar. Select Preferences... (or press Cmd-comma). Deselect 'Start Docker when you log in' on the General tab. Close the Preferences window. Quit Docker (Cmd-Q or use the menu).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTechradarView Question on Stackoverflow
Solution 1 - Dockeruser2628688View Answer on Stackoverflow
Solution 2 - DockerU.V.View Answer on Stackoverflow
Solution 3 - DockerKalrav J ParsanaView Answer on Stackoverflow
Solution 4 - DockerAdrian MannellaView Answer on Stackoverflow