Docker-compose run with isolated service sets?
I have the following setup:
db:
image: postgres:latest
app:
...
links:
- db
When I try to run twice docker-compose run app testcommand
, it reuses the db container. Is it possible to create an app to create another db container?
What I need:
- app_run_1 ---> db_1
- app_run_2 ---> db_2
I am trying to isolate services to run tests at the same time.
+3
source to share
1 answer
You can start isolated socket services using the COMPOSE_PROJECT_NAME
env variable .
All teams respect this env variable and use different container prefixes.
$ COMPOSE_PROJECT_NAME="app1" docker-compose run --rm app bash
Creating network "app1_default" with the default driver
Creating app1_db_1
$ docker-compose stop
Stopping app1_db_1 ... done
0
source to share