How to use compose environment variables in docker ENTRYPOINT

  docker, docker-compose

Environment variables don’t appear to work in ENTRYPOINT. It is my understanding that the shell form of ENTRYPOINT will expand ENV variables at run time, but this doesn’t to appear to work for ENV_CONFIG_INT in the example below. What have I done wrong in the following example?

Dockerfile

ENTRYPOINT [ "yarn", "run", "app-${ENV_CONFIG_INT}" ]

Compose yaml

  test:
    image: testimage/test:v1.0
    build:
      context: .
      dockerfile: Dockerfile
    env_file:
      - ./docker.env
    environment:
    - ENV_CONFIG_INT=1

Error:

error Command "app-${ENV_CONFIG_INT}" not found.

Replacing the value with a static int of say 1 fixes the issue, however I want the value to be dynamic at runtime.

Thanks in advance.

Source: Docker Questions

LEAVE A COMMENT