If I have a great many services defined in a docker-compose project, how can I exclude a service from the default docker-compose up
command?
For example, I
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.