變量集中管理方便修改和查閱mysql
config
LOG_DB="mysql://root:root@127.0.0.1:3306/test" WEB="http://web:80"
模板 docker-compose.template.yaml
web
version: '2' services: web: url: "$WEB" environment: LOG_DB: "$LOG_DB"
build.sh
#!/bin/bash config=`cat ./config` templ=`cat ./docker-compose.template.yaml` printf "$config\ncat << EOF\n$templ\nEOF" | bash > ./docker-compose.yaml
version: '2' services: web: url: "http://web:80" environment: LOG_DB: "mysql://root:root@127.0.0.1:3306/test"