Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't docker-compose 'down' take an optional [SERVICE...] argument?

docker-compose down does not have a [SERVICE...] argument.
Per docker-compose down --help:

Usage: down [options]

I would like to be able to bring just one of my many containers down. I know that I can down a single container using docker down instead of docker-compose down, but I'm wondering why doesn't the docker-compose down command take an optional [SERVICE...] argument?

All of the following docker-compose commands do take an optional [SERVICE...] argument:

docker-compose build
docker-compose create
docker-compose kill
docker-compose logs
docker-compose pause
docker-compose restart
docker-compose rm
docker-compose start
docker-compose stop
docker-compose unpause
docker-compose up

My docker-compose --version is 1.9.0

like image 472
Rob Bednark Avatar asked Jan 03 '17 19:01

Rob Bednark


2 Answers

The following command is the equivalent of docker down for a single service:

docker-compose rm -s -v my_service

Usage: rm [options] [SERVICE...]

Options:
-s, --stop Stop the containers, if required, before removing
-v Remove any anonymous volumes attached to containers

like image 114
André Henrique Mendes Avatar answered Oct 18 '22 20:10

André Henrique Mendes


There is no docker down. The corresponding docker command is closer to: docker stop; docker rm

From docker-compose down:

Stops containers and removes containers, networks, volumes, and images created by up.

By default, the only things removed are:

  • Containers for services defined in the Compose file
  • Networks defined in the networks section of the Compose file
  • The default network, if one is used

If docker-compose down removes networks also, then by removing one container, it should also automatically disconnect the other containers from these networks, which might be undesirable or confusing.

It could change so that by default docker down does not remove the networks, but that change might cause backwards-compatibility issues with the command.

This is just an assumption.

like image 1
Marinos An Avatar answered Oct 18 '22 20:10

Marinos An