如何在控制台中设置Docker-compose参数?

我的Docker容器将通过bash脚本进行设置。

在我的docker-compose.yml文件(通过docker docker-compose up在bash文件中调用)中,我有几个参数:

 version: "2" services: nginx: build: ./Dockerfiles/wordpress-nginx expose: - "80" depends_on: - fpm links: - fpm container_name: wordpress-nginx args: - site_title=Example - admin_email=test@test.co - site_url=www.testcase001.com - admin_user=admin - admin_pass=qwerty - ssl_domain=www.testcase001.com - dbname=testcase - dbuser=testcase - dbpass=testcase - dbhost=testcase fpm: build: ./Dockerfiles/php-fpm expose: - "9000" container_name: fpm 

现在我的问题是这样的:

我怎样才能从命令行设置参数?

例如:
我想设置site_title参数: site_title docker-compose up --something-to-set-the-site_title-argument

您可以在您docker-compose.yaml文件中使用环境variables,例如:

 args: - site_title: $SITE_TITLE 

在你的Bash脚本中,你可以像这样设置标题环境variables:

 #!/bin/bash SITE_TITLE="My new title" docker-compose up -d 

$SITE_TITLE环境variables应该在您的撰写configuration中使用。