Challenge - 5 Problems
Docker Compose Dev Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of docker-compose up with multiple services
You run
What will you see in the terminal output immediately after running the command?
docker-compose up with this docker-compose.yml file:version: '3.8'
services:
web:
image: nginx:alpine
ports:
- "8080:80"
db:
image: postgres:13
environment:
POSTGRES_PASSWORD: example
What will you see in the terminal output immediately after running the command?
Docker
version: '3.8' services: web: image: nginx:alpine ports: - "8080:80" db: image: postgres:13 environment: POSTGRES_PASSWORD: example
Attempts:
2 left
💡 Hint
Think about what
docker-compose up does by default with multiple services.✗ Incorrect
The
docker-compose up command starts all services defined in the file. Both nginx and postgres containers will start, and their logs will stream together in the terminal.❓ Configuration
intermediate2:00remaining
Correct volume syntax for live code reload
You want to mount your local
./app folder into the container at /usr/src/app to enable live code reload during development. Which volume syntax in docker-compose.yml is correct?Attempts:
2 left
💡 Hint
Local path comes first, then container path separated by a colon.
✗ Incorrect
The correct syntax for mounting a local folder is
local_path:container_path. Option D correctly mounts ./app to /usr/src/app.❓ Troubleshoot
advanced2:00remaining
Why does docker-compose fail with 'port is already allocated' error?
You have this
You run
docker-compose.yml snippet:services:
web:
image: nginx
ports:
- "8080:80"
api:
image: node
ports:
- "8080:3000"You run
docker-compose up and get an error: Bind for 0.0.0.0:8080 failed: port is already allocated. What is the cause?Docker
services:
web:
image: nginx
ports:
- "8080:80"
api:
image: node
ports:
- "8080:3000"Attempts:
2 left
💡 Hint
Host ports must be unique across all services.
✗ Incorrect
Both services map host port 8080 to different container ports. Host port 8080 cannot be used twice, causing the error.
🔀 Workflow
advanced2:00remaining
Order of commands to update code in a running dev environment
You have a running dev environment with
docker-compose up. You updated your local source code and want the container to use the new code without restarting the whole environment. What is the correct order of commands?Attempts:
2 left
💡 Hint
You only need to rebuild and restart the containers to apply code changes.
✗ Incorrect
First rebuild images with
docker-compose build, then restart containers with docker-compose restart to apply changes without stopping the whole environment.✅ Best Practice
expert2:00remaining
Choosing the best way to share environment variables securely
You want to share sensitive environment variables like database passwords with your dev containers using Docker Compose. Which approach is best practice?
Attempts:
2 left
💡 Hint
Think about secure storage and avoiding exposing secrets in files.
✗ Incorrect
Using Docker Swarm secrets with
secrets in Compose is the most secure way to handle sensitive data, avoiding exposure in files or command history.