Docker plays a pivotal role in modern containerized application development, with powerful networking and orchestration features. This chapter focuses on advanced networking (Overlay, Macvlan, IPVLAN), linking containers, Docker Compose, Docker Swarm for scaling and load balancing, and Kubernetes basics. These Docker MCQ questions and answers will boost your expertise.
What is the primary purpose of the Overlay network in Docker? a) Enables communication between containers on the same host b) Allows containers on different hosts to communicate c) Manages external DNS resolution d) Provides IPv6 addressing for containers
Which Docker network driver allows you to assign MAC addresses directly to containers? a) Overlay b) Host c) Macvlan d) Bridge
What is a key feature of the IPVLAN network driver? a) Directly exposes the container to the physical network b) Only supports single-host communication c) Requires manual container linking d) Lacks support for VLAN tagging
Which network driver is best suited for connecting multiple Docker hosts in a Swarm cluster? a) Host b) Overlay c) Bridge d) None of the above
How does the Macvlan driver differ from the Overlay driver? a) Macvlan operates at the Ethernet level, while Overlay works at Layer 3 b) Macvlan is faster than Overlay for multi-host communication c) Overlay requires external routing, while Macvlan does not d) Both are identical in functionality
Topic 2: Linking Containers
What is the purpose of linking containers in Docker? a) To share the same Docker network b) To enable direct communication between containers c) To create isolated storage volumes d) To run containers in detached mode
Which command is used to link two Docker containers? a) docker link b) docker network connect c) docker-compose link d) docker connect
Container linking is mostly replaced by which modern Docker feature? a) Docker Volumes b) Overlay Networks c) Docker Compose d) Kubernetes
What happens if a container linked to another container stops running? a) The linked container stops as well b) The link is removed permanently c) The linked container loses communication d) The network settings remain unaffected
Why is linking containers considered outdated in Docker? a) It increases resource usage b) It is replaced by networks with better isolation and flexibility c) Linking fails in multi-host setups d) Containers cannot share storage when linked
Topic 3: Docker Compose for Multi-Container Applications
What is the purpose of Docker Compose? a) To orchestrate container clusters b) To define and run multi-container Docker applications c) To manage Docker image builds d) To set up physical networking for Docker
In a docker-compose.yml file, which key defines a service? a) network b) volumes c) services d) build
Which command is used to start containers defined in a docker-compose.yml file? a) docker compose up b) docker start c) docker run d) docker-compose run
How does Docker Compose scale services? a) By adding replicas through the scale command b) By connecting multiple Docker hosts c) Through automatic load balancing d) By using Kubernetes
Which of the following is NOT a valid field in a docker-compose.yml file? a) depends_on b) ports c) volumes d) database
Topic 4: Load Balancing and Scaling with Docker Swarm
What is Docker Swarm primarily used for? a) Managing Docker images b) Load balancing and scaling containers c) Monitoring container health d) Networking multiple containers
Which command initializes a Docker Swarm? a) docker swarm init b) docker swarm create c) docker init d) docker node init
How does Docker Swarm distribute workloads? a) Using a round-robin strategy b) Based on container size c) Through manual allocation d) Using random selection
Which role is assigned to a Swarm node that manages tasks? a) Leader b) Worker c) Orchestrator d) Manager
What is the primary benefit of using Docker Swarm for scaling? a) Automatic fault tolerance and high availability b) Faster data replication across nodes c) Reduced memory usage in containers d) Single-host execution
Topic 5: Introduction to Kubernetes
What is Kubernetes? a) A programming language for Docker containers b) An orchestration platform for managing containerized applications c) A storage solution for container data d) A tool for compressing container images
In Kubernetes, what is a Pod? a) The smallest deployable unit that can hold one or more containers b) A physical server in a cluster c) A network driver for Docker d) A configuration file for scaling
What is the purpose of a Kubernetes Service? a) To store container logs b) To expose Pods to external or internal traffic c) To define volumes for containers d) To manage networking within Docker
Which component in Kubernetes is responsible for scheduling Pods? a) kube-proxy b) kubelet c) kube-scheduler d) etcd
What does the kubectl command-line tool do? a) Manages Kubernetes clusters b) Starts Docker containers c) Configures Docker networks d) Sets up storage volumes
What is the main difference between Docker Swarm and Kubernetes? a) Swarm is used for development, Kubernetes for production b) Kubernetes offers more features for large-scale deployments c) Swarm does not support container networking d) Kubernetes requires Docker Compose
Which Kubernetes object is used for scaling applications? a) ReplicaSet b) Deployment c) Pod d) Service
What is the function of a Kubernetes Ingress? a) Manages container storage b) Controls external HTTP/S access to services in a cluster c) Creates Pods in a specific namespace d) Monitors cluster health
Which component stores the state of a Kubernetes cluster? a) kubelet b) etcd c) kube-controller-manager d) kube-scheduler
What is a Node in Kubernetes? a) A virtual network b) A machine (physical or virtual) where containers run c) A Docker image repository d) A type of container storage
Answers
Qno
Answer (Option with Text)
1
b) Allows containers on different hosts to communicate
2
c) Macvlan
3
a) Directly exposes the container to the physical network
4
b) Overlay
5
a) Macvlan operates at the Ethernet level, while Overlay works at Layer 3
6
b) To enable direct communication between containers
7
a) docker link
8
b) Overlay Networks
9
c) The linked container loses communication
10
b) It is replaced by networks with better isolation and flexibility
11
b) To define and run multi-container Docker applications
12
c) services
13
a) docker compose up
14
a) By adding replicas through the scale command
15
d) database
16
b) Load balancing and scaling containers
17
a) docker swarm init
18
a) Using a round-robin strategy
19
d) Manager
20
a) Automatic fault tolerance and high availability
21
b) An orchestration platform for managing containerized applications
22
a) The smallest deployable unit that can hold one or more containers
23
b) To expose Pods to external or internal traffic
24
c) kube-scheduler
25
a) Manages Kubernetes clusters
26
b) Kubernetes offers more features for large-scale deployments
27
b) Deployment
28
b) Controls external HTTP/S access to services in a cluster
29
b) etcd
30
b) A machine (physical or virtual) where containers run