Reputation: 44629
If I run multiple docker-compose run
of a container, it creates multiple versions of the main container, but it shares the linked ones.
Is there any way to boot a completely independant container stack for every runs?
Right now I have:
$ docker-compose run web &
$ docker-compose run web &
$ docker ps
CONTAINER ID IMAGE NAMES
a579904eca2d www_web www_web_run_2
cb8f07ef0ca4 www_web www_web_run_1
d3f5e6343200 www_db www_db_1
But I want to have
CONTAINER ID IMAGE NAMES
a579904eca2d www_web www_web_run_2
cb8f07ef0ca4 www_web www_web_run_1
d3f5e6343200 www_db www_db_1
d3f5e6343200 www_db www_db_2
Where each web containers get its own DB container.
Upvotes: 0
Views: 345
Reputation: 28523
The docker-compose
binary help gives an option of:
-p, --project-name NAME Specify an alternate project name (default: directory name)
You can do something like:
docker-compose -p stack1 up -d
docker-compose -p stack2 up -d
Which would give you:
stack1_web_1
stack1_db_1
stack2_web_1
stack2_db_1
This would allow you to do something like docker-compose -p stack1 run web cat /etc/os-release
to choose a specific container to work on. It should also preserve links per stack. For example, if you had a link for db
in the web
service, stack1_web_1
would be linked to stack1_db_1
and stack2_web_1
would be linked to stack2_db_1
.
Upvotes: 4