---
title: "Docker: Containerization Fundamentals"
description: "Test your knowledge of Docker fundamentals with a quiz covering containers, images, Dockerfiles, networking, volumes, Docker Compose, and containerization best practices."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/docker-containerization-fundamentals-quiz
---

# Docker: Containerization Fundamentals

Welcome to the Docker Basics Quiz! This quiz covers fundamental Docker concepts, containerization, and best practices. Each question is multiple-choice, and you'll find hints to help you along the way. Good luck!

## Questions

### 1. Which Dockerfile instruction specifies the base image for a new container?

- `SOURCE`
- `FROM`
- `BASE`
- `ROOT`

**Hint:** It is almost always the first line of the file.

### 2. Which command is used to build an image from a Dockerfile?

- `docker create`
- `docker build`
- `docker commit`
- `docker update`

**Hint:** Think of "constructing" something.

### 3. What is the primary difference between CMD and ENTRYPOINT?

- `CMD` defines variables while `ENTRYPOINT` defines paths
- `ENTRYPOINT` sets the executable; `CMD` sets default arguments
- `CMD` executes at build time; `ENTRYPOINT` executes at runtime
- `ENTRYPOINT` is optional; `CMD` is mandatory for all images

**Hint:** One is easily overridden by CLI arguments, the other is the "fixed" executable.

### 4. Which command displays the list of currently running containers?

- `docker images`
- `docker ps`
- `docker stats`
- `docker logs`

**Hint:** Think of "process status".

### 5. What does the -d flag do when running a container?

- Deletes the container automatically upon exit
- Starts the container in detached background mode
- Enables interactive mode with a pseudo-terminal
- Download updates for the image before starting

**Hint:** It allows the container to run in the background.

### 6. Which instruction allows you to set environmental variables within a Dockerfile?

- `VAR`
- `SET`
- `ENV`
- `ARG`

**Hint:** Short for Environment.

### 7. What is a Docker "Layer"?

- An isolated virtual network segment
- A read-only filesystem change from a command
- A security wrapper around the host kernel
- A snapshot of the system memory state

**Hint:** Every instruction in a Dockerfile creates one.

### 8. How do you stop all running Docker containers at once?

- `docker stop --all`
- `docker stop $(docker ps -q)`
- `docker system halt`
- `docker kill --force`

**Hint:** It involves nesting a command inside "docker stop".

### 9. Which Docker network driver is the default for standalone containers?

- `Overlay`
- `Bridge`
- `Host`
- `None`

**Hint:** Think of a physical network connector.

### 10. What is the purpose of a Docker ".dockerignore" file?

- Prevents specific build errors from stopping the process
- Excludes local files from being sent to the build context
- Restricts the container from accessing external IP ranges
- Hides the resulting image from being seen on Docker Hub

**Hint:** Prevents sending unnecessary files to the Docker daemon.

### 11. Which command allows you to enter a running container and start a shell?

- `docker attach`
- `docker exec -it <id> /bin/bash`
- `docker connect`
- `docker open`

**Hint:** You "execute" a command inside it.

### 12. What is the command to delete a specific Docker image?

- `docker rm`
- `docker rmi`
- `docker delete`
- `docker drop`

**Hint:** Short for Remove Image.

### 13. What is a "Volume" in Docker?

- A method for limiting container disk usage
- A persistent storage area managed by Docker
- A collection of compressed image layers
- A virtualized network bandwidth controller

**Hint:** The preferred mechanism for persisting data.

### 14. In "docker run -p 8080:80 nginx", which port is the host port?

- 80
- 8080
- Both ports act as host ports
- The host port is randomly assigned

**Hint:** The format is <Host Port>:<Container Port>.

### 15. Which instruction defines the directory where subsequent commands will be executed?

- `SETDIR`
- `WORKDIR`
- `CD`
- `PATH`

**Hint:** Think of "change directory".

### 16. What is "Multi-stage building"?

- Compiling images for multiple CPU types
- Using separate stages to reduce final image size
- Running the build process on multiple hosts
- Automating the push to various registries

**Hint:** Using multiple FROM statements in one Dockerfile.

### 17. Which command is used to see the metadata (IP, Config, etc.) of a container?

- `docker logs`
- `docker inspect`
- `docker info`
- `docker meta`

**Hint:** You "examine" or "inspect" the details.

### 18. What is the purpose of "Docker Hub"?

- A local graphical tool for image editing
- A public registry for sharing container images
- A dashboard for monitoring container RAM
- The primary engine that executes containers

**Hint:** A central "library" for Docker.

### 19. What is "Copy-on-Write" (CoW)?

- A command to duplicate files from the host
- A strategy that copies files only when modified
- A script that backups container data daily
- A network protocol for syncing containers

**Hint:** How Docker handles changes to files in image layers.

### 20. Which command pulls an image from a registry without running it?

- `docker run`
- `docker pull`
- `docker fetch`
- `docker import`

**Hint:** Think of "tugging" or "fetching".

### 21. What does "docker system prune" do?

- Updates the Docker engine to the latest version
- Removes unused data like stopped containers
- Deletes all active and running containers
- Optimizes the host kernel for containerization

**Hint:** A "cleanup" command.

### 22. Which Dockerfile instruction is used to document intended ports?

- `PUBLISH`
- `EXPOSE`
- `LISTEN`
- `PORT`

**Hint:** It doesn't actually open the port on the host.

### 23. What is a "Dangling Image"?

- An image with a critical security vulnerability
- An image that has no name tag or reference
- An image that is currently in the process of pulling
- An image that is corrupted and cannot be started

**Hint:** An image with no name or tag.

### 24. Which command starts a previously stopped container?

- `docker run`
- `docker start`
- `docker resume`
- `docker up`

**Hint:** Opposite of stop.

### 25. What is the default user in most Docker images if not specified?

- `admin`
- `root`
- `default`
- `docker`

**Hint:** The most powerful user.

### 26. Which command logs you into a Docker registry?

- `docker auth`
- `docker login`
- `docker signin`
- `docker access`

**Hint:** Very intuitive name.

### 27. What is Docker Compose used for?

- Modifying the layers of a single image
- Running multi-container apps using YAML files
- Automatically updating the host OS security
- Converting VM images into Docker containers

**Hint:** Defining and running multi-container applications.

### 28. Which flag is used to name a container during "docker run"?

- -t
- --name
- --id
- -n

**Hint:** Double hyphen followed by the word.

### 29. What is the purpose of the "HEALTHCHECK" instruction?

- To monitor the RAM usage of the host server
- To check if the application inside is functional
- To scan the image layers for security risks
- To restart the Docker daemon if it crashes

**Hint:** Tells Docker how to test if the container is still working.

### 30. What command shows the history of an image?

- `docker logs`
- `docker history`
- `docker layers`
- `docker inspect`

**Hint:** Shows the layers and commands that created the image.
