1

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?
3
  • That version of compose is rather old. Why isn't it more recent? Commented Sep 20, 2020 at 17:49
  • @MichaelHampton well... Apparently, that's the newest version available here on Debian 10... Should probably install it from Docker repos instead. Commented Sep 20, 2020 at 22:19
  • I don't think Docker ships packages for docker-compose. I can't find them anyway. Commented Sep 20, 2020 at 22:27

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.