Docker Compose - Image title

When you run docker-compose up -d , by default the build image will contain the name of the current folder.

So for example, for this docker-compose.yml file, my image will be called: dockersymfony_php , because my current folder is called docker-symfony , and I specified php for my image in my yaml file

php: build: ./docker/php container_name: symfony 

Is there a way to override this? Like content_name to rename container ...

I know the docker build -t command. can do this, but I need to use the docker-compose.yml file .

+6
source share
2 answers

Currently, all you can do is configure the project name (the first part of the name before underlining) using the -p flag:

docker-compose -p COMPOSE_PROJECT_NAME

In the next version, you can use image to set the name: https://github.com/docker/compose/issues/2092

+5
source

As of January 2018, with version 3 of Docker, you can use content_name to specify a name. An example can be found here https://www.handsonarchitect.com/2018/01/docker-compose-tip-how-to-avoid-sql.html

0
source

All Articles