Docker compose env variables not working?

installing rocket-chat using docker-compose

OS version: Ubuntu 20.04
App version: docker.io 20.10.12
Steps to reproduce:

  1. fresh install ubuntu 20.04
  2. install docker.io docker-compose, config docker run without sudo
  3. curl compose.yml and .env from https://github.com/RocketChat/Docker.Official.Image
  4. rename compose.yml to docker-compose.yml , env.example to .env
  5. docker-compose up -d

got error:

ERROR: Invalid interpolation format for "rocketchat" option in service "services": "registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest"

then I change the
"registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest"
in the docker-compose.yml to
registry.rocket.chat/rocketchat/rocket.chat:5.4.3

the the error come to

ERROR: Invalid interpolation format for "rocketchat" option in service "services": "${MONGO_URL:-mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"

So, I assume that the docker-compose env variable doesn’t work on my machine.
How could I fix it?

You forgot to share the version of your Docker Compose which would be probably the only relevant information :slight_smile:

The example is for Docker Compose v2, and since you renamed compose.yml to docker-compose.yml and used docker-ompose up -d instead of docker compose up -d, I guess you are using an older version.

1 Like

I encountered this error a few minutes ago and I was able to solved it by simply added version: ‘3.5’ to the first line of the compose.yml file for docker-compese engine (or runner) to recognise the version of the compose file you’re using, not the version of the docker compose engine.

RocketChat does not add the version to the file themselves which might be oblivion.

’

The new Compose v2 ignores that version number in the compose file. If your client required it, that is the old compose and you should upgrade to the new compose. Otherwise you can have compatibility issues with newer docker daemons.