I have the following setup:
db:
image: postgres:latest
app:
...
links:
- db
When I try to run docker-compose run app testcommand twice, it reuses the db container. Is it possible to make app create another db container?
What I'm after is:
I'm trying to isolate the services in order to run tests concurrently.
You can achieve this by running each command with a different project name. Use the --project-name flag or the COMPOSE_PROJECT_NAME environment variable:
$ docker-compose --project-name=p1 run -d app testcommand
# creates p1_db_1, p1_app_run_1
$ docker-compose --project-name=p2 run -d app testcommand
# creates p2_db_1, p2_app_run_1
Works like a charm. Thank you and @bfirsh for fig and compose, it's been really helpful. Keep up the good work guys.
Most helpful comment
You can achieve this by running each command with a different project name. Use the
--project-nameflag or theCOMPOSE_PROJECT_NAMEenvironment variable: