Top Docker Fundamentals, Architecture, and Basic CLI Questions Answers for Interview

Prepare for your Docker and DevOps interviews with these carefully selected Docker Fundamentals, Architecture, and Basic CLI MCQs. This set covers core Docker Basic Fundamentals, Architecture, and Basic CLI. Each question includes clear answers and explanations to help you strengthen your understanding and boost interview confidence.

By the end of this article, you’ll be well-equipped to handle a variety of Docker Fundamentals, Architecture, and Basic CLI interview questions and demonstrate your proficiency in automating IT tasks efficiently and effectively.

1. What is Docker primarily designed to do ?

A) Manage physical server hardware
B) Create, deploy, and manage applications in isolated containers
C) Replace the host operating system entirely
D) Act as a browser-based code editor

Correct Answer: B
Explanation: Docker is an open-source platform that uses containerization to package software and its dependencies into a single unit. This ensures the application behaves the same way across different environments. It automates deployment within lightweight containers to enable consistent execution.

2. In which programming language is Docker written ?

A) Python
B) Java
C) Go
D) C++

Correct Answer: C
Explanation: Docker is written in the Go programming language. It takes advantage of specific Linux kernel features to deliver its functionality.

3. How do Docker containers differ from traditional Virtual Machines (VMs)?

A) Containers share the host OS kernel
B) Containers require a full guest OS
C) VMs are lighter and faster than containers
D) Containers virtualize hardware instead of the OS

Correct Answer: A
Explanation: Unlike VMs that run a complete operating system on top of a hypervisor, containers share the host machine’s OS kernel. This makes containers much more lightweight and efficient in terms of resource usage.

4. What is a Docker image ?

A) A running instance of an application
B) A graphical UI for managing containers
C) A read-only template used to create containers
D) A physical snapshot of the server hardware

Correct Answer: C
Explanation: A Docker image is a static, read-only blueprint that contains the code, libraries, and settings needed to run an application. It serves as the source or template from which containers are launched.

5. Which component acts as the “control center” or background service for Docker ?

A) Docker Client
B) Docker Hub
C) Docker Daemon
D) Docker Desktop

Correct Answer: C
Explanation: The Docker daemon (dockerd) is a persistent background service that manages Docker objects like images and containers. It listens for API requests from the client to perform these management tasks.

6. What is the purpose of the Docker Hub ?

A) To compile source code into binaries
B) To act as a public registry for sharing and storing Docker images
C) To provide a physical data center for containers
D) To manage local network firewalls

Correct Answer: B
Explanation: Docker Hub is a cloud-based registry service where developers can store, share, and manage both public and private Docker images. It is the default registry Docker uses to pull images if they are not found locally.

7. Which command is used to download an image from a registry ?

A) docker pull
B) docker push
C) docker fetch
D) docker get

Correct Answer: A
Explanation: The docker pull command downloads a specific Docker image from a registry like Docker Hub to your local machine. If no tag is specified, it pulls the “latest” version by default.

8. Which command is used to list only currently running containers ?

A) docker ps
B) docker ls
C) docker ps -a
D) docker list

Correct Answer: A
Explanation: The docker ps command provides a summary of all active, running containers on the host. To see both running and stopped containers, you must add the -a flag.

9. What happens when a container enters the “stopped” state ?

A) The container is permanently deleted
B) The process inside exits, but the container still exists on disk
C) All data in its volumes is immediately erased
D) It automatically restarts by default

Correct Answer: B
Explanation: When a container stops, it finishes its execution, but its filesystem persists until it is explicitly removed. You can view stopped containers using docker ps -a.

10. Which command creates and starts a new container in one step ?

A) docker start
B) docker create
C) docker run
D) docker build

Correct Answer: C
Explanation: The docker run command is the primary way to launch an application because it creates a new container instance from an image and starts it immediately. If the image is not available locally, it will pull it first.

11. How do you run a container in the background so it doesn’t occupy the terminal ?

A) Using the -d flag
B) Using the -it flag
C) Using the –rm flag
D) Using the -bg flag

Correct Answer: A
Explanation: Running a container with the -d or –detach flag puts it in “detached mode,” meaning it runs in the background. You will receive the container ID as confirmation, and your terminal will remain free.

12. Which command allows you to view the real-time output (logs) of a container ?

A) docker stats
B) docker inspect
C) docker see
D) docker logs

Correct Answer: D
Explanation: The docker logs command retrieves the standard output and error streams from a running or stopped container. Using the -f flag allows you to continuously stream the logs as they happen.

13. Which command is used to check the version of the Docker client and server ?

A) docker -v
B) docker info
C) docker version
D) docker –help

Correct Answer: C
Explanation: The docker version command provides detailed information about both the Docker client (CLI) and the Docker daemon (server) versions. It is used to check for updates or verify compatibility.

14. What is the command to view low-level system-wide information about Docker ?

A) docker ps
B) docker images
C) docker version
D) docker info

Correct Answer: D
Explanation: The docker info command displays extensive details about the system configuration, including the number of containers, images, and storage drivers being used. It is helpful for checking the overall health of the Docker installation.

15. Which signal does docker stop send to the container’s main process first ?

A) SIGTERM
B) SIGSTOP
C) SIGKILL
D) SIGINT

Correct Answer: A
Explanation: docker stop sends a SIGTERM signal to allow the application to shut down gracefully without data corruption. If it doesn’t stop within a grace period, it sends a SIGKILL to force the termination.

16. Which command removes a stopped container from the system ?

A) docker rmi
B) docker rm
C) docker delete
D) docker kill

Correct Answer: B
Explanation: The docker rm command permanently deletes one or more stopped containers to free up system resources. It does not remove the Docker image associated with the container.

17. Which command is used to remove a Docker image ?

A) docker rmi
B) docker rm
C) docker image prune
D) docker purge

Correct Answer: A
Explanation: The docker rmi command deletes one or more images from local storage. If you want to remove all unused (dangling) images at once, you would use docker image prune.

18. Which flag is used with docker run to open an interactive terminal session inside a container ?

A) -d
B) -p
C) -it
D) -v

Correct Answer: C
Explanation: The -i flag keeps the standard input open, and the -t flag allocates a pseudo-TTY terminal. Together as -it, they allow you to interact directly with the container’s shell.

19. What does the command docker ps -a -q do ?

A) Lists all running containers with details
B) Lists only the IDs of all containers (running and stopped)
C) Removes all containers immediately
D) Starts all containers in quiet mode

Correct Answer: B
Explanation: The -a flag includes all containers, and the -q flag filters the output to show only the numeric container IDs. This is often used in scripts to perform bulk actions on containers.

20. Which command provides live resource usage metrics (CPU, memory, etc.) ?

A) docker info
B) docker inspect
C) docker top
D) docker stats

Correct Answer: D
Explanation: The docker stats command displays a continuous, real-time stream of CPU usage, memory usage, and network I/O for all running containers. It is essential for monitoring container performance and identifying bottlenecks.

21. What is the “Union File System” in Docker ?

A) A layered system that combines read-only images with a writable container layer
B) A system to join multiple physical hard drives
C) A network protocol for file sharing
D) A security feature to encrypt files

Correct Answer: A
Explanation: Docker uses a union file system to combine multiple static image layers into a single virtual filesystem for the container. When a container runs, Docker adds a thin writable layer on top for any changes made during execution.

22. What happens to data in a container’s writable layer when the container is deleted ?

A) It is automatically moved to Docker Hub
B) it is preserved on the host disk permanently
C) it is archived into a .tar file
D) it is lost unless a volume or bind mount was used

Correct Answer: D
Explanation: Docker containers are ephemeral, meaning any changes to the container’s own filesystem disappear when the container is removed. To persist data, you must use external storage mechanisms like volumes.

23. Which command is used to execute a new command inside an already running container ?

A) docker run
B) docker start
C) docker exec
D) docker attach

Correct Answer: C
Explanation: The docker exec command allows you to run additional commands or open a shell inside a container that is already active. Unlike docker run, it does not create a new instance.

24. How do you restart a container that was previously stopped ?

A) docker run <name>
B) docker start <name>
C) docker create <name>
D) docker build <name>

Correct Answer: B
Explanation: The docker start command resumes work on an existing container that is currently in a stopped state. Unlike docker run, it does not create a fresh container from the image.

25. What is a “Docker Host” ?

A) The physical or virtual machine running the Docker Engine
B) A website that hosts images
C) A container that manages other containers
D) The user who owns the Docker account

Correct Answer: A
Explanation: The Docker host is the system (Linux, Windows, or Mac) where the Docker Engine is installed and running. It provides the primary environment for managing and executing containers.

26. Which command creates a custom image from a Dockerfile ?

A) docker build
B) docker create
C) docker run
D) docker image new

Correct Answer: A
Explanation: The docker build command reads the instructions in a Dockerfile to assemble a new, custom Docker image. It typically uses a tag flag (-t) to name the resulting image.

27. What is the purpose of the .dockerignore file ?

A) To stop Docker from running on specific OS versions
B) To exclude unnecessary files from being sent to the build context
C) To ignore security vulnerabilities in images
D) To hide containers from the docker ps list

Correct Answer: B
Explanation: A .dockerignore file prevents large or sensitive files from being copied into the Docker image during the build process. This helps reduce the final image size and improves build speed.

28. What does the command docker system prune do ?

A) Updates all images to the latest version
B) Scans the system for viruses
C) Restarts the Docker daemon
D) Deletes all unused data, including stopped containers and dangling images

Correct Answer: D
Explanation: This powerful command performs a quick cleanup by removing stopped containers, unused networks, and images that aren’t associated with any containers. It is used to free up disk space and tidy the environment.

29. Which command is used to upload an image to Docker Hub ?

A) docker pull
B) docker upload
C) docker push
D) docker save

Correct Answer: C
Explanation: The docker push command uploads a local image to a registry like Docker Hub so it can be shared or deployed elsewhere. You must be authenticated via docker login before pushing.

30. Which command shows the layer history of a Docker image ?

A) docker inspect
B) docker history
C) docker layers
D) docker logs

Correct Answer: B
Explanation: The docker history command displays the sequence of layers and commands used to build an image. It is useful for debugging how an image was created and checking individual layer sizes.

31. What is the primary benefit of “Container Isolation” ?

A) It prevents processes in one container from interfering with others or the host
B) It allows containers to run on different physical hard drives
C) It makes containers invisible to the internet
D) It automatically copies data between containers

Correct Answer: A
Explanation: Each container runs in its own isolated environment, ensuring that software conflicts and dependency issues are avoided. This isolation is achieved using Linux kernel features like namespaces.

32. What does “portability” mean in the context of Docker ?

A) Containers can be easily renamed
B) An image can run consistently on any machine that supports Docker
C) Containers can be moved to physical USB drives
D) Docker works on all mobile devices

Correct Answer: B
Explanation: Once a Docker image is built, it can be run without modification on a developer’s laptop, a test server, or a production cloud environment. This eliminates the classic “it works on my machine” problem.

33. Which command is used to stop a container immediately without a grace period ?

A) docker stop
B) docker pause
C) docker kill
D) docker rm -f

Correct Answer: C
Explanation: The docker kill command forces a container to shut down instantly by sending a SIGKILL signal. This is used when a container is unresponsive to a normal stop command.

34. What command would you use to find the IP address of a running container ?

A) docker ps
B) docker network ls
C) docker logs
D) docker inspect

Correct Answer: D
Explanation: The docker inspect command provides detailed JSON output about a container, including its network settings and assigned IP address. You can use the –format flag to extract just the IP address.

35. What is the difference between docker start and docker run ?

A) start creates a new container; run restarts an old one
B) run creates and starts a new container; start resumes a stopped one
C) They are identical and can be used interchangeably
D) run is only for images; start is only for volumes

Correct Answer: B
Explanation: docker run is used to launch a new instance from an image, while docker start is used to bring an existing stopped container back to a running state.

36. Which command freezes all processes within a container ?

A) docker stop
B) docker freeze
C) docker pause
D) docker suspend

Correct Answer: C
Explanation: The docker pause command suspends all processes in a container, essentially freezing its current state. It is used to temporarily free up CPU cycles without stopping the container.

37. How do you resume processes in a container that was previously paused ?

A) docker start
B) docker unpause
C) docker resume
D) docker restart

Correct Answer: B
Explanation: The docker unpause command resumes all processes in a container that was frozen. The container returns to an active running state exactly where it left off.

38. Which component translates Docker CLI commands into instructions for the engine ?

A) REST API
B) Docker Registry
C) Docker Compose
D) Docker Machine

Correct Answer: A
Explanation: The Docker client interacts with the daemon using a REST API over UNIX sockets or a network interface. This API defines the methods available for performing Docker operations.

39. What is a “Dangling Image” ?

A) An image that is currently being downloaded
B) An image used by more than ten containers
C) An image that has been corrupted during a push
D) An unused image layer that is no longer associated with any tagged image

Correct Answer: D
Explanation: Dangling images occur when you build a new version of an image with the same name and tag, leaving the old layers without a reference. They consume disk space and can be cleared using docker image prune.

40. Which command shows only the IDs of all images on your machine ?

A) docker images -q
B) docker images –id
C) docker list images
D) docker rmi -q

Correct Answer: A
Explanation: The -q or –quiet flag with docker images filters the output to show only the unique Image IDs. This is often used for bulk deletion of images in automation scripts.

41. What is the command to create an archive (.tar) of an image to move it offline ?

A) docker export
B) docker commit
C) docker save
D) docker load

Correct Answer: C
Explanation: The docker save command exports an image to a tarball archive. This allows you to move images to computers that do not have internet access.

42. What command is used to restore an image from a .tar file ?

A) docker save
B) docker load
C) docker import
D) docker push

Correct Answer: B
Explanation: The docker load command is the opposite of save; it restores an image from a portable tar archive into your local Docker list.

43. Which command displays the running processes inside a specific container ?

A) docker top
B) docker ps
C) docker stats
D) docker exec

Correct Answer: A
Explanation: The docker top command works like the Linux top utility but is targeted at the processes inside a single container. It shows active process IDs and their resource usage.

44. What is the default state of a newly created container if it hasn’t been started ?

A) Running
B) Stopped
C) Created
D) Exited

Correct Answer: C
Explanation: When you use the docker create command, the container is generated in a “created” state. It is writable and ready to run but has not yet executed its main process.

45. Which command combines docker stop and docker start ?

A) docker redo
B) docker refresh
C) docker restart
D) docker run

Correct Answer: C
Explanation: The docker restart command stops a running container and then immediately starts it again. It is often used to apply configuration changes or fix minor glitches.

46. What is the “UnionFS” thin layer created when a container starts ?

A) The Read-Only layer
B) The Container Layer (Read-Write)
C) The Host Layer
D) The Network Layer

Correct Answer: B
Explanation: Every time a container is created from an image, Docker adds a new writable “container layer” on top. Any changes made (like adding or deleting files) are saved here and exist only while the container exists.

47. Which flag allows you to assign a human-readable name to a container ?

A) -t
B) –name
C) -id
D) –label

Correct Answer: B
Explanation: By default, Docker assigns random names to containers, but you can use the –name flag to give it a specific name for easier management. Names must be unique on the host.

48. Which command is used to list all the images currently stored on your local machine ?

A) docker ps
B) docker pull
C) docker ls
D) docker images

Correct Answer: D
Explanation: The docker images command lists all images in your local cache, showing their repository, tags, IDs, and sizes. This helps you see what is available to run without pulling from a registry.

49. What does the command docker container prune do ?

A) Removes all stopped containers
B) Deletes all images
C) Restarts the host computer
D) Deletes all volumes

Correct Answer: A
Explanation: This command specifically targets stopped containers and removes them all in one go to clean up the environment.

50. Which command is used to log in to a registry server ?

A) docker push
B) docker search
C) docker login
D) docker auth

Correct Answer: C
Explanation: The docker login command authenticates your user account with a registry like Docker Hub. This is necessary to access private repositories or push images.



Leave a Reply

Your email address will not be published. Required fields are marked *

prepforcareers.com

Our platform focuses on providing carefully prepared IT interview MCQs with clear answers and easy explanations. Each question is designed to help you strengthen your fundamentals and improve your confidence before facing real interviews.