Divide docker services into various environments/stages using the docker profile
You may have different services you want to run through in various environments like testing, deployment, etc. Sometimes it isn't worth having multiple files for a few services or specifying services using their names in docker compose command. hence here comes the docker profile, you can run your services separately only by using the --profile option in the docker compose command. One file; one command format; multi-environment services.
here is the way to use docker profile:
compose service definition:
services:
example-service:
<snip>
profiles:
- <profile name 1>
- <profile name 2>
specify which profile services should be run in compose command line:
docker compose --profile <profile name> up
# or define profile as env
COMPOSE_PROFILE=<profile name> docker compose up
easy and simple, hope you enjoy it :)