DCA DCA Docker Networking 2 — Questions and Answers
Question 1: What is the purpose of DNS resolution in user-defined Docker networks?
- To assign IP addresses to containers
- To allow containers to communicate using container names as hostnames (Correct answer)
- To route traffic between Docker hosts
- To expose container ports to the host
Correct answer: To allow containers to communicate using container names as hostnames
User-defined networks include an embedded DNS server that allows containers to resolve each other by container name.
Question 2: Which network driver assigns a MAC address and connects containers directly to the physical network?
- overlay
- bridge
- macvlan (Correct answer)
- host
Correct answer: macvlan
The macvlan network driver assigns a unique MAC address to each container, making it appear as a physical device on the network.
Question 3: What happens to containers connected to the 'none' network driver?
- They share the host network stack
- They are connected to all available networks
- They have no network access (Correct answer)
- They use a bridge connection
Correct answer: They have no network access
The none network driver completely disables all networking for the container.
Question 4: Which command connects a running container to an additional network?
- docker network connect my-network my-container (Correct answer)
- docker container network add my-network my-container
- docker attach network my-network my-container
- docker network join my-network my-container
Correct answer: docker network connect my-network my-container
The `docker network connect` command attaches a running container to an existing network.
Question 5: What is the default subnet used by Docker's default bridge network (docker0)?
- 192.168.0.0/16
- 10.0.0.0/8
- 172.17.0.0/16 (Correct answer)
- 192.168.1.0/24
Correct answer: 172.17.0.0/16
Docker's default bridge network uses the 172.17.0.0/16 subnet by default.
Question 6: In Docker Swarm, which network is automatically created to handle load balancing for published service ports?
- A default bridge network
- An ingress overlay network (Correct answer)
- A host network
- A macvlan network
Correct answer: An ingress overlay network
Docker Swarm automatically creates an ingress overlay network to implement the routing mesh for published ports.
What is the purpose of DNS resolution in user-defined Docker networks?