Problem
I want to run webapp through Docker, running 2 containers as a unit.
1 container starts my web server (Tomcat 7).
Another container runs my database (Postgres 9.4).
I can start docker-compose up, and Docker can expand my two containers, as indicated in mine docker-compose.yml:
web:
build: .
ports:
- "5000"
links:
- db
db:
image: postgres
I want to be able to deploy another copy of my webapp by launching again docker-compose up, but this leads to the fact that Docker tells me that the containers are already running:
$ docker-compose up -d
Creating composetest_db_1
Creating composetest_web_1
$ docker-compose up -d
composetest_db_1 is up-to-date
composetest_web_1 is up-to-date
My job
I circumvented this problem by using the option -pto give new copies different names for the projects:
$ docker-compose -p project1 up -d
...
Successfully built d3268e345f3d
Creating project1_web_1
$ docker-compose -p project2 up -d
...
Successfully built d3268e345f3d
Creating project2_web_1
Unfortunately, this creates new images for each copy:
$ docker images
project1_web latest d3268e345f3d 2 hours ago 682 MB
project2_web latest d3268e345f3d 2 hours ago 682 MB
Question
docker-compose ?