I would like to be able to use env variables inside docker-compose.yml, with values passed in at the time of docker-compose up. This is the example.

I am doing this today with basic docker run command, which is wrapped around my own script.
Is there a way to achieve it with compose, without any such bash wrappers?

proxy:
  hostname: $hostname
  volumes:
    - /mnt/data/logs/$hostname:/logs
    - /mnt/data/$hostname:/data

16 Answers
16

Leave a Reply

Your email address will not be published. Required fields are marked *