Interview Q&A beginner

Docker Basics MCQ

Test your Docker fundamentals with 30 multiple-choice questions covering images, containers, Dockerfile, networking, volumes, and Docker Compose.

12 min read 31 Questions
1 What is Docker?
2 What is the difference between a Docker image and a Docker container?
3 Which Dockerfile instruction sets the base image for subsequent instructions?
4 Which command is used to build a Docker image from a Dockerfile?
5 What does the EXPOSE instruction in a Dockerfile do?
6 Which command lists all running Docker containers?
7 What is the purpose of the .dockerignore file?
8 What is the difference between the COPY and ADD instructions in a Dockerfile?
9 What is the difference between ENTRYPOINT and CMD in a Dockerfile?
10 Which command runs a command inside a running container?
11 What does the -d flag do when running 'docker run -d nginx'?
12 What is a Docker volume?
13 What is the difference between a Docker named volume and a bind mount?
14 Which Docker network driver creates an isolated network on a single host and is the default for user-defined networks?
15 What does docker stop do differently from docker kill?
16 Which command removes all stopped containers, unused networks, dangling images, and build cache?
17 What is a multi-stage Docker build?
18 What is Docker Compose used for?
19 Which Docker Compose command starts all services defined in docker-compose.yml in detached mode?
20 What does the RUN instruction do in a Dockerfile?
21 How do you map port 8080 on the host to port 80 inside a container?
22 What does docker images show?
23 What is a dangling Docker image?
24 Which Dockerfile instruction sets environment variables that are available both during build and at container runtime?
25 What is the purpose of the WORKDIR instruction in a Dockerfile?
26 How do you view the logs of a container named 'webserver'?
27 What restart policy should you set to make a container always restart unless explicitly stopped?
28 What does 'docker inspect <container>' return?
29 What is a Docker registry?
30 Which instruction in a Dockerfile defines the user that the container runs as?
31 What is the correct way to set a HEALTHCHECK in a Dockerfile?

Scenario Based

Scenario-based questions for Docker are coming soon.

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form