Environment variables from env fiile in entrypoint in docker-compose.yml

Viewed 2331

I would like to use variable from env-file in docker-compose in entry point:

  # environment.env
  HOST=example.com

  # docker-compose.yml
  some_service:
    ...
    env_file: ['environment.env']
    entrypoint: ['myexecutable', '--host', '$HOST']

Is there any way to do that? I found only one solution:

  # docker-compose.yml
  some_service:
    ...
    env_file: ['environment.env']
    entrypoint: sh -c 'myexecutable --host $$HOST'

But it looks violates docker conception "one process per container" (because there will be 2 processes: sh and myexecutable). And container does not stop normally, I have to kill it with docker kill or docker-compose kill.

2 Answers
Related