Docker MCQs – Docker Networking

Docker networking is a vital concept for enabling communication between containers, hosts, and external systems. It allows containers to connect with one another and the outside world while maintaining security and isolation.

These top MCQs on Docker networking cover the fundamental concepts, types of networks, and practical configurations, helping you prepare for interviews by understanding real-world networking scenarios in containerized environments.

1.) What is the default network type created when Docker is installed?

A) Bridge
B) Host
C) None
D) Overlay

Answer: Option A

Explanation: When Docker is installed, it creates a default bridge network, which is used by containers unless another network is specified.

2.) Which command lists all available Docker networks?

A) docker network ls
B) docker network list
C) docker networks
D) docker network inspect

Answer: Option A

Explanation: The docker network ls command lists all Docker networks present on the host.

3.) What is the purpose of the docker network create command?

A) To create a container
B) To create a new network
C) To connect a container to a network
D) To list all networks

Answer: Option B

Explanation: The docker network create command is used to create a new network for Docker containers.

4.) Which network driver is used for communication between containers on the same host by default?

A) None
B) Host
C) Bridge
D) Overlay

Answer: Option C

Explanation: The bridge network is the default driver used for communication between containers on the same host.

5.) What is the role of the –network flag in the docker run command?

A) To list all available networks
B) To specify the network for the container
C) To create a new network
D) To disconnect a container from the network

Answer: Option B

Explanation: The –network flag specifies the network that the container should connect to.

6.) Which network driver allows a container to share the host’s network namespace?

A) Bridge
B) None
C) Host
D) Overlay

Answer: Option C

Explanation: The host network driver allows a container to share the host’s network namespace, meaning it uses the host’s IP and ports directly.

7.) What is an “overlay network” in Docker?

A) A network that operates only on a single host
B) A deprecated network type
C) A private network for internal Docker use
D) A network that connects multiple Docker daemons across hosts

Answer: Option D

Explanation: An overlay network connects multiple Docker daemons, enabling communication between containers running on different hosts.

8.) What is the purpose of the docker network inspect command?

A) To delete a network
B) To view detailed information about a network
C) To create a new network
D) To connect a container to a network

Answer: Option B

Explanation: The docker network inspect command displays detailed information about a Docker network, including connected containers and configurations.

9.) Which network driver disables all networking for a container?

A) Bridge
B) Host
C) None
D) Overlay

Answer: Option C

Explanation: The none network driver disables all networking for the container, creating a completely isolated environment.

10.) How do you connect a running container to an existing network?

A) docker network connect <network> <container>
B) docker network attach <network> <container>
C) docker connect <network> <container>
D) docker attach <network> <container>

Answer: Option A

Explanation: The docker network connect command connects a running container to an existing network.

Leave a Reply

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