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"
            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 failed to fetch
  • 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.:

      - 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.