Docker-compose exclude service by default

Starting with docker-compose 1.28.0 the new service profiles are just made for that! With profiles you can mark services to be only started in specific profiles, for example:

services:
  webapp:
    # ...

  nginx:
    # ...
    profiles: ["nginx"]
    ports:
      - 80:80

  ssl:
    # ...
    profiles: ["ssl"]
    ports:
      - 80:80
docker-compose up # start only your webapp services
docker-compose --profile nginx up # start the webapp and nginx service
docker-compose --profile ssl up # start the webapp and ssl service
docker-compose run ssl # run the ssl service

Depending on your exact use case/setup however it may be better to split your services into multiple docker-compose.yml files.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)