Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (2.3k points)

So I learned that there are a lot of services that are defined  docker-compose.yml. I started a few of these services. I want to create only one of these and then start it up without using the other services 

These are the commands I have run :

docker-compose up -d # run all services
docker-compose stop nginx # stop only one. but it still running !!!
docker-compose build --no-cache nginx 
docker-compose up -d --no-deps # link nginx to other services

I got a nginx container by the end and I also learned that docker-compose will not kill all running containers!


1 Answer

0 votes
by (6.9k points)
selected by
Best answer

Use this command , It should work :

$docker-compose up -d --no-deps --build <service_name> 

You can refer to these optional flags that you can use with the docker compose up command :


-d, --detach: Detached mode: Run containers in the background, print new container names. Incompatible with  --abort-on-container-exit.

--no-deps: Don't start linked services.
--force-recreate:  Recreate containers even if their configuration                        and image haven't changed.

--build :  Build images before starting containers.

Also you can finish learning more about docker by getting trained in docker. You will be trained by industry professionals in this docker training.

Browse Categories