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 have an nginx service, and an ssl service. They conflict because they both consume port 80, so how can I make it so that the ssl service doesn't start unless I specifically run that service, and by default the up
command will do everything EXCEPT the ssl service?
There are two steps to stop a docker application containers: First, stop the running containers using docker-compose stop. Second, remove the stopped containers using docker-compose rm -f.
Run Docker Compose in detached mode by passing the -d flag to docker-compose up . Use docker-compose ps to review what you have running.
Description. Stops containers and removes containers, networks, volumes, and images created by up .
docker-compose up does everything so you have the option to rebuild. When you run docker-compose down it doesn't delete the image. You can delete that manually if you want.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With