Challenge - 5 Problems
Database Container Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of Docker command for running a PostgreSQL container
You run this command to start a PostgreSQL container locally:
What is the output of
docker run --name pg-test -e POSTGRES_PASSWORD=secret -d -p 5432:5432 postgres:15
What is the output of
docker ps --filter name=pg-test --format '{{.Status}}' immediately after running?Attempts:
2 left
💡 Hint
Think about what status a healthy running container shows.
✗ Incorrect
When a container starts successfully and is running, the status shows 'Up' with the time since start. 'Exited' means it stopped, 'Created' means it hasn't started, and 'Restarting' means it failed and is retrying.
❓ Configuration
intermediate2:00remaining
Correct Docker Compose service for MySQL with persistent data
Which Docker Compose service configuration correctly sets up a MySQL container with a persistent volume for data storage?
Attempts:
2 left
💡 Hint
Persistent data should be stored in the container's data directory, not config directory.
✗ Incorrect
MySQL stores data in /var/lib/mysql inside the container. Mounting a named volume there ensures data persists. Option B correctly maps the volume. Option B misses the volume name, A uses a relative path which is valid but not named volume, D mounts to wrong path.
❓ Troubleshoot
advanced2:00remaining
Diagnosing PostgreSQL container connection failure
You start a PostgreSQL container with:
But when you try to connect from your host using
What is the most likely cause?
docker run --name pg -e POSTGRES_PASSWORD=pass -d -p 5432:5432 postgres
But when you try to connect from your host using
psql -h localhost -p 5432 -U postgres, it fails with "connection refused".What is the most likely cause?
Attempts:
2 left
💡 Hint
Think about how PostgreSQL listens for connections inside the container versus outside.
✗ Incorrect
By default, PostgreSQL listens on localhost inside the container, so external connections fail unless configured to listen on 0.0.0.0. Docker port mapping alone does not expose the service if PostgreSQL is not listening on all interfaces.
🔀 Workflow
advanced2:00remaining
Order of steps to safely update a database container with data persistence
You want to update your MySQL container image to a newer version without losing data stored in a Docker volume.
Which is the correct order of steps?
Which is the correct order of steps?
Attempts:
2 left
💡 Hint
You must stop the container before pulling and restarting with new image.
✗ Incorrect
Stopping the container first ensures no data corruption. Then pull the new image, start a new container with the existing volume to keep data, and finally verify data integrity.
✅ Best Practice
expert2:00remaining
Best practice for managing secrets in database containers for local development
Which approach is the best practice for handling database passwords in Docker containers during local development?
Attempts:
2 left
💡 Hint
Consider security and convenience balance in local development.
✗ Incorrect
Using a local .env file excluded from version control keeps secrets out of code but allows easy configuration. Hardcoding is insecure, Docker secrets are complex for local dev, and empty passwords are insecure.