Background
I was deploying my docker environment to a production server when I've noticed that the application would not work. For some reason the environment variables were not set correctly inside the containers. It's also important that I define the environment via environment files.
The problem
I was able to track the problem down to the point when I realized, that docker-compose
would not expand the variables defined inside the environment file on my production server while on my development machine it does what I intuitively expect it to do.
Demo configuration
This simple configuration would work in my development environment only. In production it will yield:
ERROR: no such image: ${DISTRIBUTIVE}:${TAG}: invalid reference format: repository name must be lowercase
# .env
DISTRIBUTIVE=debian
TAG=latest
IMAGE=${DISTRIBUTIVE}:${TAG}
# docker-compose.yml
version: "3.0"
services:
service:
image: "${IMAGE}"
Possible causes of the problem
I think that maybe that's a new feature of docker-compose
(to expand the variables) and maybe it's related to the fact that I've got a fresher install of docker on my development machine.
- Dev
- docker - 19.03.12-ce
- compose - 1.27.3
- Prod
- docker - 19.03.13
- compose - 1.21.0
Questions
- Is there any documentation regarding variables inside environment files?
- If that's a new feature then what are version requirements for it?