Learn. Practice. Feel prepared.
Docker Objective Questions and Answers - Set 2
This Docker quiz contains carefully curated objective questions with correct answers and clear explanations. It is designed for developers, DevOps engineers, and interview preparation, covering containerization fundamentals and best practices. This is part 2 of the series.
Practice Docker MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
16 Which command removes a Docker image? Easy
Correct answer:
docker rmi
docker rmi removes a Docker image from the local system.
17 Which storage mechanism persists data beyond container lifecycle? Medium
Correct answer:
Volumes
Docker volumes store data independently of container lifecycle.
18 Which network type allows containers to communicate on the same host? Medium
Correct answer:
Bridge
Bridge network enables communication between containers on the same host.
19 Which command shows Docker images on the system? Easy
Correct answer:
docker images
docker images lists all locally available Docker images.
20 What does the -d flag do in docker run? Easy
Correct answer:
Detached mode
The -d flag runs the container in detached mode.
21 Which command maps a container port to a host port? Easy
Correct answer:
-p
The -p flag publishes a container port to the host.
22 Which command displays container logs? Easy
Correct answer:
docker logs
docker logs outputs the logs of a container.
23 Which Docker object defines environment variables at runtime? Medium
Correct answer:
Container
Environment variables are applied when a container is started.
24 Which command executes a command inside a running container? Medium
Correct answer:
docker exec
docker exec runs a command inside an already running container.
25 Which Docker feature reduces image size by using multiple build stages? Medium
Correct answer:
Multi-stage builds
Multi-stage builds help reduce final image size by separating build and runtime stages.
26 Which file is used to ignore files during image build? Easy
Correct answer:
.dockerignore
.dockerignore prevents specified files from being sent to the Docker build context.
27 Which command removes stopped containers? Medium
Correct answer:
docker prune
docker prune removes unused Docker objects including stopped containers.
28 Which isolation technology does Docker primarily rely on? Hard
Correct answer:
Kernel namespaces and cgroups
Docker uses Linux kernel features like namespaces and cgroups for isolation.
29 Which command starts an existing stopped container? Easy
Correct answer:
docker start
docker start starts one or more stopped containers.
30 Which Docker command shows detailed container configuration? Medium
Correct answer:
docker inspect
docker inspect provides detailed information about Docker objects.