Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

startup

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?

like image 682
Techradar Avatar asked Nov 09 '16 18:11

Techradar


People also ask

How do I stop docker containers automatically starting?

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.

Do docker containers start automatically?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.

How do I stop docker container from running in the background?

To stop a container you use the docker stop command and pass the name of the container and the number of seconds before a container is killed. The default number of seconds the command will wait before the killing is 10 seconds. Read More: Double Your Efficiency With Advanced Docker Commands.

Does restarting docker restart all containers?

For a major version upgrade, one has to tear down all running containers. With a restart policy of always , however, the containers will be restarted after the docker daemon is restarted after the upgrade.


1 Answers

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?

like image 59
user2628688 Avatar answered Sep 28 '22 18:09

user2628688