📜  在 docker compose 中访问 bash 变量 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:39.340000             🧑  作者: Mango

代码示例1
The latest Docker Compose allows you to access environment variables from your compose file. So you can source your environment variables, then run Compose like so:
set -a
source .my-env
docker-compose up -d

Then you can reference the variables in docker-compose.yml using ${VARIABLE}, like so:
db:
  image: "postgres:${POSTGRES_VERSION}"