Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Compose - Image name

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.

like image 530
Kevin Avatar asked Dec 17 '15 19:12

Kevin


2 Answers

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

like image 167
dnephin Avatar answered Sep 28 '22 06:09

dnephin


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

like image 34
Nilesh Gule Avatar answered Sep 28 '22 04:09

Nilesh Gule