How to set Docker-compose arguments in console?

My Docker containers will be set up through a bash script.

In my docker-compose.yml file (which is called through docker-compose up inside the bash file) I have a few arguments:

  • Docker swarm node hostnames are the same
  • How does docker run differ from running a command from a shell within the container
  • Docker build command output unavailable
  • Docker container running but browser refuse to connect
  • kubernetes how to set the maximum size of the log file?
  • Missing Carriage Return in Docker for Mac Containers
  • version: "2"
            build: ./Dockerfiles/wordpress-nginx
                - "80"
                - fpm
                - fpm
            container_name: wordpress-nginx
                - site_title=Example
                - admin_user=admin
                - admin_pass=qwerty
                - dbname=testcase
                - dbuser=testcase
                - dbpass=testcase
                - dbhost=testcase
            build: ./Dockerfiles/php-fpm
                - "9000"
            container_name: fpm

    Now my question is this:

    How can I set the arguments from the command line?

    For example:
    I want to set the site_title argument: docker-compose up --something-to-set-the-site_title-argument

  • I'm unable to connect Docker Remote API using nodejs hosted in AWS
  • non-loading with www dir, nginx, nette - set nginx path?
  • What's the difference between the docker commands: run, build, and create
  • How can I automatically run a docker container on/after image build?
  • Docker container from docker cloud on windows
  • docker-compose run , Link to previously running container
  • One Solution collect form web for “How to set Docker-compose arguments in console?”

    You can use environment variables in your docker-compose.yaml file, e.g.:

      - site_title: $SITE_TITLE

    In your Bash script, you can then set the title environment variable like this:

    SITE_TITLE="My new title"
    docker-compose up -d

    The $SITE_TITLE environment variable should then be used in your compose configuration.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.