Last Updated On
Welcome to the Docker Quiz! This blog post features 25 multiple-choice questions that explore advance concepts of Docker.
1. How do Docker containers achieve process isolation on the host system?
a) Virtual Machines
b) Hypervisors
c) Namespaces and cgroups
d) Dedicated resources
Answer 1
c) Namespaces and cgroups
Namespaces are a feature of the Linux kernel that provide isolation for resources such as process IDs, network, user IDs, and file systems.
Docker uses cgroups to allocate resources efficiently among containers running on the same host, preventing one container from consuming excessive resources and impacting others.
2. What is the purpose of a Dockerfile?
a) To create virtual machines
b) To optimize application code
c) To store environment variables
d) To define and build Docker images
Answer 2
d) To define and build Docker images
A Dockerfile contains a set of instructions to define and build a Docker image, specifying dependencies, configuration, and application code.
3. What does the Dockerfile contain?
a) Compiled source code
b) Docker images
c) Binary data
d) Instructions for building a Docker image
Answer 3
Instructions for building a Docker image
A Dockerfile is a text file that contains a set of instructions used to automatically build a Docker image. These instructions define everything needed to assemble the image, such as: Base Image, Package Installation, Execution Commands, File Operations
4. How many types of volumes are there in Docker?
a) 3
b) 2
c) 4
d) 5
Answer 4
b) 2
There are two types of volumes in docker – Named volumes and Bind Mounts
5. Which of the following volume type allows you to share a directory from the host’s filesystem into the container?
a) Named volumes
b) Bind Mounts
Answer 5
b) Bind Mounts
The bind mount volume type allows you to share a directory from the host’s filesystem into the container.
6. In which of the following volume type docker chooses the host location?
a) Named volumes
b) Bind Mounts
Answer 6
a) Named volumes
In the Named volume type docker chooses the host location, whereas you decide the host location in the bind mount type of volume.
7. Which command is used to remove unused Docker objects, such as containers and images?
a) docker prune
b) docker clean
c) docker system prune
d) docker remove
Answer 7
c) docker system prune
8. To list all the networks linked with Docker on the host, the ____ command is used.
a) docker network list
b) docker network ls
c) docker ls
d) network ls
Answer 8
b) docker network ls
To list all the networks linked with Docker on the host, the docker network ls command is used.
9. What is port binding in Docker?
a) Binding environment variables
b) Assigning internal ports to external ones
c) Binding memory resources
d) Binding IP addresses to containers
Answer 9
b) Assigning internal ports to external ones
Port binding in Docker refers to the process of linking internal ports within a Docker container to external ports on the host system. This allows applications running inside the container to communicate with external networks or systems
10. Which of the following is a tool that was built to assist define and distribute multi-container applications?
a) Docker setup
b) Docker compose
c) Docker notify
Answer 10
b) Docker compose
Docker Compose is a tool that was built to assist define and distribute multi-container applications.
11. Which of the following command is used to display the statistics of a running container?
Choose one option
a) Docker statistics
b) Stats
c) Docker statics
d) Docker stats
Answer 11
d) Docker stats
The stats command is used to display the statistics of a running container.
12. Which command is used to view the logs of a running container?
Choose one option
a) docker view [container ID]
b) docker logs [container ID]
c) docker inspect [container ID]
d) docker output [container ID]
Answer 12
b) docker logs [container ID]
13. What is the default Docker network mode?
Choose one option
a) host
b) none
c) bridge
d) overlay
Answer 13
c) bridge
14. After making changes to a running container, how can you save those changes into an image?
Choose one option
a) docker save
b) docker commit
c) docker store
d) docker snapshot
Answer 14
b) docker commit
15. What does the `ENTRYPOINT` directive do in a Dockerfile?
a) Sets an environment variable
b) Specifies the command that will run on container start
c) Exposes a port
d) Confirms the image build
Answer 15
b) Specifies the command that will run on container start
16. What is the function of the `Dockerfile` directive `COPY`?
Choose one option
a) Copies files and directories from localhost to the image
b) Moves data between volumes
c) Copies data between containers
d) Duplicates Docker images
Answer 16
a) Copies files and directories from localhost to the image
17. What is the syntax used to specify base image in a Dockerfile?
Choose one option
a) FROM [image name]
b) BASE [image name]
c) SOURCE [image name]
d) INITIAL [image name]
Answer 17
a) FROM [image name]
18. What is the primary function of the .dockerignore file?
Choose one option
a) To list all images to be pulled from the Docker Hub
b) To specify commands to run inside a container
c) To prevent certain files and directories from being copied into an image
d) To provide metadata about a Docker image
Answer 18
c) To prevent certain files and directories from being copied into an image
The .dockerignore file allows users to exclude files and directories from being copied to the image during the build process, much like .gitignore does for git repositories.
19. In a docker-compose.yml file, what is the function of the depends_on key?
a) Specifies the base images for services
b) Specifies the build context for services
c) Specifies the order in which services are started
d) Specifies the network links between services
Answer 19
c) Specifies the order in which services are started
In a docker-compose.yml file, the depends_on key indicates the order in which services should be started. A service with a depends_on key will not start until the services it depends on have been started.
20. What is the primary purpose of Docker Swarm?
a) Image version management
b) Multi-host container orchestration
c) Container storage optimization
d) Automated container build pipeline
Answer 20
b) Multi-host container orchestration
Docker Swarm is a native clustering and orchestration tool for Docker. It allows you to create and manage a swarm of Docker nodes and orchestrate services across multiple hosts.
21. What command initializes a node as a Docker Swarm manager?
a) docker swarm init
b) docker swarm start
c) docker swarm create
d) docker swarm manager
Answer 21
a) docker swarm init
The docker swarm init command initializes the current node as a Docker Swarm manager, which manages the infrastructure of a swarm.
22. How can you inspect the details of a Docker network?
a) docker network view NETWORK_NAME
b) docker network show NETWORK_NAME
c) docker network detail NETWORK_NAME
d) docker network inspect NETWORK_NAME
Answer 22
d) docker network inspect NETWORK_NAME
The docker network inspect command is used to display detailed information about a network.
23. Which command creates a Docker volume?
a) docker storage create
b) docker add volume
c) docker volume create
d) docker create
Answer 23
c) docker volume create
The docker volume create command creates a new Docker volume for persistent storage.
24. Why is Docker commonly integrated with CI/CD pipelines?
a) Consistent environments across testing and production
b) Easier dependency management
c) Faster build and deployment times
d) All of the mentioned
Answer 24
d) All of the mentioned
Docker integration with CI/CD ensures faster deployments, dependency management, and environment consistency.
25. Why is Kubernetes often paired with Docker?
a) For debugging local machines
b) For virtualizing operating systems
c) For orchestrating large-scale container deployments
d) For building individual containers
Answer 25
c) For orchestrating large-scale container deployments
Kubernetes orchestrates, deploys, and manages containers at scale, complementing Docker’s container creation capabilities.
We would love to hear from you! Please leave your comments and share your scores in the section below