如https://docs.docker.com/compose/compose-file/#envfile中所述,我可以将环境变量放入特定文件中。但我无法做到。在过去几个小时内无法弄清楚,即使我已经将docker(Docker版本1.12.5)和docker-compose(版本1.9.0)都升级到了lateste版本。docker-compose无法从SOME.env文件中检索变量
搬运工-compose.yml:
version: '2' services: box: image: busybox env_file: tt.env command: echo $RACK_ENV
tt.env
# Set Rails/Rack environment RACK_ENV=development
的输出搬运工-构成了将是这样的:
WARNING: The RACK_ENV variable is not set. Defaulting to a blank string.
Creating network "test_default" with the default driver
Creating test_box_1
Attaching to test_box_1
box_1 |
test_box_1 exited with code 0
这意味着tt.env文件中设置的变量未成功检索。请让我知道我错了。
“.ENV”的作品,但我需要的功能,可指定该文件名来切换环境。 – Cross