Script Valley
Docker: Complete Course
Docker Fundamentals/Assessment

Practice & Assessment

Test your understanding of Docker Fundamentals

Multiple Choice Questions

5
1

What is the key architectural difference between a Docker container and a virtual machine?

2

You run `docker rm my-app` after writing files inside that container. What happens to those files?

3

Which command runs an nginx container in the background and maps host port 9090 to container port 80?

4

What is the correct use case for a bind mount over a named volume?

5

A container exits immediately after `docker run ubuntu`. What is the most likely cause?

Coding Challenges

1
1

Run a PostgreSQL container with persistent storage

Using only the Docker CLI (no Compose), run a PostgreSQL 16 container named 'pg-dev' with: (1) a named volume called 'pg-dev-data' mounted at /var/lib/postgresql/data, (2) POSTGRES_PASSWORD set to 'devpass', (3) POSTGRES_DB set to 'appdb', (4) port 5432 mapped to host port 5433. Then verify the container is running with docker ps, connect using `docker exec -it pg-dev psql -U postgres`, run `\l` to list databases and confirm 'appdb' appears. Stop the container, remove it, then re-run the same command and verify data persists. Document the exact commands used. Estimated time: 20 minutes.

Easy

Mini Project

1

Containerized Static File Server

Build a local static file server using Docker. Create a directory called 'site' containing an index.html with your name and a short bio. Run an nginx container that serves this directory using a bind mount mapped to /usr/share/nginx/html, with port 8080 on the host mapped to port 80 in the container. The container must run in detached mode with the name 'static-server'. Verify the site loads at http://localhost:8080. Then edit index.html on the host while the container is running and confirm the change appears without restarting the container. Stop and remove the container, then repeat using a named volume instead of a bind mount — observe the difference in behavior when you try to edit files. Write a short README listing the commands used for each approach.

Easy