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:

  • Apply NetEM WAN delay on a docker container interface
  • AWS EB, Play Framework and Docker: Application Already running
  • Docker calling unit tests
  • Prevent skip in docker-compose
  • How to get Container Id of Docker in Jenkins
  • Elastic search with docker does not start
  • 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

  • docker COPY .env file fail
  • Building from one image and adding dependency to another
  • docker build with --build-arg with multiple variables
  • Parse a string to array in node.js
  • How do I copy the files from one directory to another using a dockerfile?
  • Have to set up eval $(dinghy env) everytime. Cannot connect to the Docker daemon. Is the docker daemon running on this host?
  • 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.