How to use environment variables in docker compose

后端 未结 13 737
孤街浪徒
孤街浪徒 2020-11-28 01:02

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

13条回答
  •  自闭症患者
    2020-11-28 01:09

    Since 1.25.4, docker-compose supports the option --env-file that enables you to specify a file containing variables.

    Yours should look like this:

    hostname=my-host-name
    

    And the command:

    docker-compose --env-file /path/to/my-env-file config
    

提交回复
热议问题