Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stopping Docker Containers from Being there on Startup

Tags:

docker

Whenever I start Docker on my Mac, there are four containers that come along for the ride and start up automatically.

$ docker ps

    Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

//starts docker, makes tea    

$ docker ps
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS              PORTS                                                                         NAMES
d78483fa7f27        magento/magento2devbox-web:latest   "/usr/local/bin/en..."   4 weeks ago         Up 5 minutes        5000/tcp, 9000/tcp, 44100/tcp, 0.0.0.0:32774->22/tcp, 0.0.0.0:32773->80/tcp   magento2devbox_web_03b003abaeb68eadd315c2e4763d0326
01f62a720e40        mysql:5.6                           "docker-entrypoint..."   4 weeks ago         Up 5 minutes        0.0.0.0:32772->3306/tcp                                                       magento2devbox_db_03b003abaeb68eadd315c2e4763d0326
005e0708d8f7        magento/magento2devbox-web:latest   "/usr/local/bin/en..."   6 months ago        Up 5 minutes        5000/tcp, 9000/tcp, 44100/tcp, 0.0.0.0:32770->22/tcp, 0.0.0.0:32769->80/tcp   magento2devbox_web_258e08743d8e54a4b3e6acfd3b2d7159
00b38cf0fdb9        mysql:5.6                           "docker-entrypoint..."   6 months ago        Up 5 minutes        0.0.0.0:32768->3306/tcp                                                       magento2devbox_db_258e08743d8e54a4b3e6acfd3b2d715

How do I tell (Docker? The containers?) that I don't need these four containers to start up automatically anymore?

like image 341
Alan Storm Avatar asked Dec 05 '22 13:12

Alan Storm


1 Answers

Check the restart policy of those containers using docker inspect NAME|ID. If it is always or on-failure, then you have the explanation.

To change the restart policy, use docker update --restart <new policy>.

These two commands set the restart policy to no for all running containers and then kill them all (make sure you understand this before doing it):

docker update `docker ps -q` --restart no
docker kill `docker ps -q`

After that, restart your docker daemon and you should see nothing from docker ps.

like image 75
mozz100 Avatar answered Jan 06 '23 10:01

mozz100