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:

  • npm install error with docker - kurento application
  • Docker config : Celery + RabbitMQ
  • Dockerfile entrypoint not lunching on interactive mode
  • Docker DNS Error
  • WordPress local dev environment image
  • persist and share data from docker mongo container (with docker)
  • 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
    

    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

  • Docker failed to fetch http://deb.debian.org/debian/dists/jessie/InRelease
  • Saving changes in docker project
  • How to share a folder between my Mac and a Docker container
  • Using a unique-hosted data volume containers with v3 in swarm
  • Why not run uwsgi instances as root
  • alpine package py-pip missing
  • 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.:

    args:
      - site_title: $SITE_TITLE
    

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

    #!/bin/bash
    
    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.