Disable docker project autorun

I have a project for creating dockers using Docker for Mac, which starts automatically when the computer boots.

Usually I start a project with docker-compose up -d , but even run docker-compose stop before disabling autostart again at boot.

I do not know how to do that. How to disable it?

+18
source share
4 answers

Today I had the same problem that all containers start when my dev laptop loads, since restart: always was installed in .yml files.

Since I don't want to touch the .yml files, I just found out (thanks Bobby) how to change this parameter to:

 docker update --restart=no <MY-CONTAINER-ID> 
+16
source

Try using docker-compose down instead of docker-compose stop

down

Stops containers and deletes containers, networks, volumes, and images created up. Networks and volumes defined as external are never deleted .

Stop

Stops containers without deleting them. They can be started again at docker-compose start .

+5
source

restart: no - default mode. Your docker-compose file has a line with restart: no or restart: unless-stopped . It also means that when you boot your system, it (and) starts the container again as long as the docker daemon is running. the details
You need to change restart to no or on-failure , for example:

 version: '2.1' services: backend: restart: on-failure build: args: USER_ID: ${USER_ID} context: codebase/namp-backend dockerfile: Dockerfile.dev ports: - "5001:5001" - "5851:5851" volumes: - ./codebase/namp-backend:/codebase environment: 

In addition, docker-compose down in most cases gives the same result - do not start containers when you start (docker) the system, except that the containers will be deleted after that, and not stopped.

+1
source

Next to restart: unless-stopped , delete existing containers and recreate them.

 docker-compose down docker-compose up -d 

Now this will work as expected:

 docker-compose stop sudo service docker restart docker-compose ps # should NOT HAVE containers running docker-compose up -d sudo service docker restart docker-compose ps # should HAVE containers running 
0
source

Source: https://habr.com/ru/post/1012993/


All Articles