When you are running a docker-compose up -d command, by default the build image is going to take the name of the current folder.
So for example for this docker-compose.yml file my image will be named: dockersymfony_php because my current folder is named docker-symfony and I indicated php for my image in my yaml file
php:
build: ./docker/php
container_name: symfony
Is there a way to override that ? Like container_name to renaming the container...
I know that the command docker build -t . can do it but I need to use my docker-compose.yml file.
Currently all you can do is customize the project name (the first part of the name before the underscore) using -p
flag:
docker-compose -p COMPOSE_PROJECT_NAME
In the next release you'll be able to use image
to set the name: https://github.com/docker/compose/issues/2092
As of Jan 2018, with version 3 of Docker compose you can use container_name to specify the name. An example can be found here https://www.handsonarchitect.com/2018/01/docker-compose-tip-how-to-avoid-sql.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With