What is the difference between the `–build` and `–force-recreate` flags to `docker-compose up`?

As mentioned in a doc, or the help of docker-compose up, –build: build images before starting containers. –force-recreate: Recreate containers even if their configuration and image haven’t changed. –build is a straightforward and it will create the docker images before starting the containers. The –force-recreate flag will stop the currently running containers forcefully and spin … Read more

docker compose environment variable for command

The variables are being read by Compose when the file is parsed. But setting environment only provides values to the container, not to the file parsing. If you’re trying to pass those variables into the container, you need to escape them in the command using an extra $ -Dconfig.home=$${CONF_HOME} -Dcomponent.name=LMS -Denv=$${APP_ENV} -Duser.dir=/tmp/ -DLMS_UUID=$${UUID If you’re … Read more

Inheritance or nesting with docker compose

With docker-compose 1.6 this should be possible. Create a docker-compose.yml with your common services: service01: image: image01 links: – service02 service02: image: image02 And a second file, docker-compose.prod.yml with your unique services: service03: image: image03 links: – service02 Now you can start service 01, 02 and 03 with this command: docker-compose -f docker-compose.yml -f docker-compose.prod.yml … Read more

stack name with docker-compose

There are several ways to do it: 1. Using –project-name (or -p) option when calling docker-compose: docker-compose -p “my-app” up Caution: -p “my-app” must come before up. 2. COMPOSE_PROJECT_NAME environment variable: export COMPOSE_PROJECT_NAME=my-app docker-compose up 3. COMPOSE_PROJECT_NAME in .env file Create a file named .env in the project root and set the COMPOSE_PROJECT_NAME environment variable … Read more