I have a docker-compose.yml
php-fpm:
build: ./php
container_name: php-fpm-symfony
links:
- db
ports:
- 9000:9000
- 8000:8000
working_dir: /var/www/html/
volumes:
- ../:/var/www/html
volumes_from:
- data
tty: true
env_file:
- ./docker.env
entrypoint: /entrypoint.sh
When I'm executing my docker-compose up -d
I would like to pass an argument, which is my container name, to name dynamically my container.
Is it possible with docker-compose?
Like for example:
docker-compose up -d "-variable=symfony" // ???
And:
php-fpm:
build: ./php
container_name: php-fpm-$(variable)
Something which works like that...
container_name: php-fpm-${FOOBAR}
and thenFOOBAR=symfony docker-compose ...
?WARNING: The FOOBAR variable is not set. Defaulting to a blank string.
% grep FOO docker-compose.yml container_name: foo-${FOOBAR} % FOOBAR=hellotest docker-compose up Recreating foo- Attaching to foo-hellotest foo-hellotest | Hello, World foo-hellotest exited with code 0
. We can see the 'hellotest' coming from the environment.