Search code examples
dockerdocker-compose

How to make profile default for docker-compose?


I have a docker compose file with 2 exclusive profiles local and dev, which we use for local testing and pulling the dev environment down for debugging.

Is there a way to default to local so that we can use docker-compose build without specifying --profile and docker will default to local?


Solution

  • You'll want to use the COMPOSE_PROFILES environment variable. To always have it set, you could put:

    COMPOSE_PROFILES=local in /etc/environment

    or...

    export COMPOSE_PROFILES=local in ~/.bashrc or ~/.zshrc

    Then restart your shell. You can type this to ensure your shell has picked up the env var:

    echo $COMPOSE_PROFILES