How to pass environment variable to docker-compose up

You have two options:

  1. Create the .env file as already suggested in another answer.
  2. Prepend KEY=VALUE pair(s) to your docker-compose command, e.g:

    KB_DB_TAG_VERSION=kb-1.3.20-v1.0.0 docker-compose up
    

    Exporting it earlier in a script should also work, e.g.:

    export KB_DB_TAG_VERSION=kb-1.3.20-v1.0.0
    docker-compose up
    

Leave a Comment