These days I had a Quick glimpse at Docker Compose and created a docker-compose.yml
for planets right away.
Let's start with creating the infrastructure services first:
mongodb:
image: planets/mongodb
ports:
- "27017"
There are only two things we configure in this snippet: The image and the ports.
The next snippet adds links and environment variables to the mix:
server:
image: planets/server
ports:
- "8080"
links:
- mongodb
environment:
- SPRING_PROFILES_ACTIVE=prd
homepage:
image: planets/homepage
ports:
- "28080:8080"
links:
- server
environment:
- SPRING_PROFILES_ACTIVE=prd
The ports decleration of the service homepage is a bit different (28080:8080
) which means the WWW port is exposed to the outside world as 28080
. In the previous examples the port was only available to other containers using a link.
Change into the directory that contains your docker-compose.yml
and fire up the application with a single command:
$ docker-compose up
Update the whole application:
$ docker-compose stop -t 30
$ docker-compose pull
$ docker-compose up -t 30 -d
Nice addition in the Docker universe...
Per default the containers are prefixed with the directory name where the Docker compose file is located.
If you want to change the prefix you can add -p <prefix>
to your compose commands.