Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose down with a non-default yml file name

I have a non-default docker-compose file name (docker-compose-test.yml). There is only one service defined in it.

I am starting the container using "docker-compose -f docker-compose-test.yml up"

I am trying to stop the container started above using docker-compose down, but it is not working.

I am getting below error,

ERROR:         Can't find a suitable configuration file in this directory or any         parent. Are you in the right directory?          Supported filenames: docker-compose.yml, docker-compose.yaml 

I understand that it is looking for default docker compose file name. Is there a way to specify the custom config file name during docker-compose down?

like image 498
Venkat Teki Avatar asked Feb 10 '18 05:02

Venkat Teki


People also ask

Can I change docker-compose file name?

The default filename is docker-compose. yml . You can name the manifest name as you like, but you have to pass the filename in the docker-compose command.

Where is the docker-compose yml file?

The Compose file is a YAML file defining services, networks and volumes. The default path for a Compose file is ./docker-compose.yml .

Do I need both Dockerfile and docker-compose yml?

Docker compose uses the Dockerfile if you add the build command to your project's docker-compose. yml. Your Docker workflow should be to build a suitable Dockerfile for each image you wish to create, then use compose to assemble the images using the build command.

What is docker-compose down?

docker-compose down - command will stop running containers, but it also removes the stopped containers as well as any networks that were created. You can take down one step further and add the -v flag to remove all volumes too.


2 Answers

You should run the docker-compose down command with the same flags that when you started the containers.

docker-compose -f docker-compose-test.yml down

like image 76
Marc Nuri Avatar answered Sep 21 '22 22:09

Marc Nuri


You can create a .env file and add the following:

COMPOSE_FILE=docker-compose-test.yml 
like image 39
Mark Parrish Avatar answered Sep 18 '22 22:09

Mark Parrish