docker-compose.yml snippet, what will be the output of docker-compose --profile debug ps?version: '3.9' services: app: image: alpine command: sleep 1000 debug: image: busybox command: sleep 1000 profiles: - debug
When you run docker-compose --profile debug up, it starts all services without a profile plus those with the 'debug' profile. So both 'app' and 'debug' services run.
docker-compose.yml service definitions correctly enables the service monitor only when the profile monitoring is active?The correct syntax uses the key profiles with a list of profile names. Option B correctly uses a list with one item 'monitoring'.
docker-compose up without specifying any profile. Why does the service not start?Services tagged with a profile only start when that profile is enabled explicitly using --profile. Running docker-compose up without profiles starts only services without any profile.
docker-compose.yml snippet, which services will start when running docker-compose --profile frontend --profile debug up?version: '3.9'
services:
backend:
image: backend:latest
frontend:
image: frontend:latest
profiles:
- frontend
debug:
image: debug:latest
profiles:
- debugServices without profiles (backend) always start. Services with profiles start only if their profile is enabled. Here, both 'frontend' and 'debug' profiles are enabled, so all three services start.
Profiles are designed to enable optional services like monitoring or debugging only when needed. This keeps production environments clean and efficient.