Home Docker compose环境变量的优先级顺序
Post
Cancel

Docker compose环境变量的优先级顺序

最近写docker-compose file时需要处理众多的环境变量,这些变量特性不一处理方式各异,特地去官方文档研究了一下docker-compose对环境变量的处理。

官方介绍的优先级顺序:

  1. Compose file
  2. Shell environment variables
  3. Environment file
  4. Dockerfile
  5. Variable is not defined

根据实际测试得到:

  1. compose文件中的environment项

  2. compose文件中的env_file项

  3. 用于compose的.env文件

有趣而特别需要注意的地方在于:

用于compose的.env文件 > compose文件中的默认值 > compose文件中的env_file项

This post is licensed under CC BY 4.0 by the author.

Docker-out-of-docker的用户组问题

树形结构数据存储之Nested Intervals