Using Spring Profiles with Docker

With Docker and the Spring Framework it is easy to run a dev and nighly environment without any changes to the Docker container itself on the same host.

Simply set the environment variable SPRING_PROFILES_ACTIVE when starting the container. This will switch the active <profile> of the Spring Application.

The following two lines will start the latest Planets dev build on port 8081 and the nightly build on port 8080.

docker run -d -p 8080:8080 -e \"SPRING_PROFILES_ACTIVE=nightly\" --name nightly-planets-server planets/server:nightly
docker run -d -p 8081:8080 -e \"SPRING_PROFILES_ACTIVE=dev\" --name dev-planets-server planets/server:latest

This can be done automatically from a CI system. The dev server contains the latest build and nightly will be deployed once a day...

Show Comments