Search code examples
dockerdocker-composedocker-container

Is there a way to prevent all the Docker containers within a service from auto restarting or starting automatically when Docker Desktop runs?


I am currently using Docker Desktop.

However, I have built services using the docker-compose up command. I have noticed that whenever we start Docker Desktop, the containers attached to each service automatically starts. Is there a way to prevent this?

I know that it is possible to set the restart policy of each container. But I don't know how to do this when there are multiple containers. Also multiple services may be using a container of the same name.

What I need is to prevent these services from starting and their containers.


Solution

  • You can use either of these commands to update your docker

    docker update --restart=no the-container-you-want-to-disable-restart

    docker update --restart=no $(docker ps -a -q)