Docker containers are the runtime instances of Docker images, encapsulating applications and their dependencies in lightweight, portable environments. Containers are the cornerstone of Docker and enable consistent application behavior across development, testing, and production.
Mastering Docker containers is essential for technical interviews, as they frequently focus on container creation, management, and optimization. These top MCQs are designed to test your knowledge and prepare you for real-world scenarios and interview challenges.
1.) What is a Docker container?
A) A virtual machine
B) A runtime instance of a Docker image
C) A tool for building Docker images
D) A Docker registry
2.) Which command is used to create and start a container?
A) docker start
B) docker create
C) docker run
D) docker init
3.) How do you list all running containers?
A) docker list
B) docker show
C) docker containers
D) docker ps
4.) How do you stop a running Docker container?
A) docker stop <container-id>
B) docker end <container-id>
C) docker terminate <container-id>
D) docker pause <container-id>
5.) Which command is used to remove a container?
A) docker rm <container-id>
B) docker delete <container-id>
C) docker remove <container-id>
D) docker rmi <container-id>
6.) How can you view the logs of a container?
A) docker view <container-id>
B) docker inspect <container-id>
C) docker logs <container-id>
D) docker history <container-id>
7.) What happens to a container if it is stopped and not removed?
A) It is automatically deleted.
B) It remains on the system and can be restarted.
C) It is moved to an archive.
D) It cannot be restarted.
8.) How can you restart a stopped container?
A) docker init <container-id>
B) docker restart <container-id>
C) docker start <container-id>
D) docker run <container-id>
9.) Which flag is used to run a container in detached mode?
A) -i
B) -d
C) –detach
D) Both B and C
10.) What does the -it flag do in the docker run command?
A) Runs the container in detached mode
B) Allocates a pseudo-TTY and keeps the container interactive
C) Runs multiple containers simultaneously
D) Specifies the image tag to use
Related