KEMBAR78
Docker | PDF | Computer Science | Computer Architecture
0% found this document useful (0 votes)
7 views14 pages

Docker

Uploaded by

pranaydodiya2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views14 pages

Docker

Uploaded by

pranaydodiya2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Docker & Kubernetes MCQ - Interview

Preparation
DOCKER MCQs
1. What is Docker?

A) Virtual Machine B) Containerization Platform C) Operating System D) Programming


Language

Answer: B) Containerization Platform Explanation: Docker is a containerization platform


that packages applications and their dependencies into lightweight, portable containers.

2. Which file is used to build Docker images?

A) docker-compose.yml B) Dockerfile C) docker.json D) build.txt

Answer: B) Dockerfile Explanation: Dockerfile contains instructions to build Docker


images with application code and dependencies.

3. What is the difference between Docker Image and Docker Container?

A) Image is running instance, Container is template B) Container is running instance, Image


is template C) Both are same D) Image is smaller than Container

Answer: B) Container is running instance, Image is template Explanation: Image is a


read-only template, Container is a running instance of an image.

4. Which command is used to build a Docker image?

A) docker create B) docker build C) docker make D) docker compile

Answer: B) docker build Explanation: docker build command creates images from
Dockerfile instructions.

5. What does the FROM instruction do in Dockerfile?

A) Sets working directory B) Specifies base image C) Copies files D) Runs commands

Answer: B) Specifies base image Explanation: FROM instruction specifies the base image
to build upon.

6. Which command lists all running containers?

A) docker ps B) docker list C) docker show D) docker containers

Answer: A) docker ps Explanation: docker ps shows all currently running containers.


7. What is Docker Hub?

A) Local storage B) Cloud-based registry C) Development tool D) Testing framework

Answer: B) Cloud-based registry Explanation: Docker Hub is a cloud-based registry


service for sharing container images.

8. Which instruction in Dockerfile exposes a port?

A) PORT B) OPEN C) EXPOSE D) LISTEN

Answer: C) EXPOSE Explanation: EXPOSE instruction informs Docker about ports the
container listens on.

9. What is the purpose of docker-compose?

A) Build single containers B) Manage multi-container applications C) Create images D)


Monitor containers

Answer: B) Manage multi-container applications Explanation: Docker Compose


manages multi-container Docker applications using YAML files.

10. Which command stops a running container?

A) docker kill B) docker stop C) docker end D) docker terminate

Answer: B) docker stop Explanation: docker stop gracefully stops a running container.

11. What is a Docker Volume?

A) Container memory B) Persistent data storage C) Network interface D) CPU allocation

Answer: B) Persistent data storage Explanation: Docker volumes provide persistent data
storage that survives container lifecycle.

12. Which instruction sets environment variables in Dockerfile?

A) SET B) VAR C) ENV D) EXPORT

Answer: C) ENV Explanation: ENV instruction sets environment variables in the container.

13. What does the -d flag do in docker run?

A) Delete container B) Debug mode C) Detached mode D) Development mode

Answer: C) Detached mode Explanation: -d flag runs container in detached (background)


mode.

14. Which command removes a Docker image?


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

Answer: C) docker rmi Explanation: docker rmi removes Docker images from local
storage.

15. What is the default network driver in Docker?

A) host B) bridge C) overlay D) none

Answer: B) bridge Explanation: Bridge is the default network driver for standalone
containers.

16. Which instruction copies files from host to container in Dockerfile?

A) MOVE B) TRANSFER C) COPY D) GET

Answer: C) COPY Explanation: COPY instruction copies files/directories from host to


container filesystem.

17. What is the difference between COPY and ADD in Dockerfile?

A) No difference B) ADD has additional features like URL download and tar extraction C)
COPY is faster D) ADD is deprecated

Answer: B) ADD has additional features like URL download and tar extraction
Explanation: ADD can download from URLs and extract tar files, while COPY is simpler.

18. Which command shows Docker system information?

A) docker info B) docker system C) docker status D) docker details

Answer: A) docker info Explanation: docker info displays system-wide information about
Docker installation.

19. What is multi-stage build in Docker?

A) Building multiple images B) Using multiple Dockerfiles C) Optimizing image size by


using multiple FROM instructions D) Running multiple containers

Answer: C) Optimizing image size by using multiple FROM instructions Explanation:


Multi-stage builds use multiple FROM instructions to create optimized final images.

20. Which command executes commands inside a running container?

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

Answer: B) docker exec Explanation: docker exec runs commands in running containers.

21. What is the purpose of .dockerignore file?


A) Ignore Docker commands B) Exclude files from build context C) Hide containers D)
Disable Docker features

Answer: B) Exclude files from build context Explanation: .dockerignore excludes


files/directories from Docker build context.

22. Which instruction sets the working directory in Dockerfile?

A) DIR B) WORKDIR C) CD D) PATH

Answer: B) WORKDIR Explanation: WORKDIR sets the working directory for


subsequent instructions.

23. What is Docker Swarm?

A) Container orchestration B) Image registry C) Development tool D) Monitoring system

Answer: A) Container orchestration Explanation: Docker Swarm is Docker's native


container orchestration platform.

24. Which command shows container logs?

A) docker log B) docker logs C) docker show-logs D) docker tail

Answer: B) docker logs Explanation: docker logs displays logs from a container.

25. What is the purpose of health checks in Docker?

A) Monitor container performance B) Check container health status C) Validate images D)


Test network connectivity

Answer: B) Check container health status Explanation: Health checks monitor container
health and report status.

KUBERNETES MCQs
26. What is Kubernetes?

A) Container runtime B) Container orchestration platform C) Operating system D)


Programming language

Answer: B) Container orchestration platform Explanation: Kubernetes is an open-source


container orchestration platform for automating deployment, scaling, and management.

27. What is a Pod in Kubernetes?


A) Single container B) Smallest deployable unit that can contain one or more containers C)
Worker node D) Storage volume

Answer: B) Smallest deployable unit that can contain one or more containers
Explanation: Pod is the smallest deployable unit in Kubernetes, containing one or more
tightly coupled containers.

28. Which component is the brain of Kubernetes cluster?

A) kubelet B) kube-proxy C) API Server D) etcd

Answer: C) API Server Explanation: API Server is the central management entity that
exposes Kubernetes API.

29. What is the purpose of kubelet?

A) Manage cluster networking B) Agent that runs on each node to manage containers C)
Store cluster data D) Load balance traffic

Answer: B) Agent that runs on each node to manage containers Explanation: kubelet is
the primary node agent that manages containers on worker nodes.

30. Which component stores all cluster data in Kubernetes?

A) API Server B) Controller Manager C) etcd D) Scheduler

Answer: C) etcd Explanation: etcd is a distributed key-value store that stores all Kubernetes
cluster data.

31. What is a Deployment in Kubernetes?

A) Single Pod B) Manages stateful applications C) Manages stateless applications with


ReplicaSets D) Network configuration

Answer: C) Manages stateless applications with ReplicaSets Explanation: Deployment


manages stateless applications by creating and managing ReplicaSets.

32. What is the difference between Deployment and StatefulSet?

A) No difference B) Deployment for stateless, StatefulSet for stateful applications C)


StatefulSet is older D) Deployment is more powerful

Answer: B) Deployment for stateless, StatefulSet for stateful applications Explanation:


Deployments manage stateless apps, StatefulSets manage stateful apps with persistent storage
and network identities.

33. What is a Service in Kubernetes?


A) Running application B) Abstraction that defines logical set of Pods and access policy C)
Storage volume D) Container image

Answer: B) Abstraction that defines logical set of Pods and access policy Explanation:
Service provides stable network endpoint for accessing Pods.

34. Which Service type exposes application to external traffic?

A) ClusterIP B) NodePort C) LoadBalancer D) All of the above

Answer: D) All of the above Explanation: NodePort and LoadBalancer expose apps
externally, ClusterIP with ingress can also expose apps.

35. What is an Ingress in Kubernetes?

A) Pod network B) HTTP/HTTPS routing to services C) Storage class D) Node configuration

Answer: B) HTTP/HTTPS routing to services Explanation: Ingress manages external


HTTP/HTTPS access to services in cluster.

36. What is a Namespace in Kubernetes?

A) Container name B) Virtual cluster for resource isolation C) Network segment D) Storage
location

Answer: B) Virtual cluster for resource isolation Explanation: Namespaces provide


virtual clusters within physical cluster for resource isolation.

37. Which command creates resources from YAML file?

A) kubectl create B) kubectl apply C) kubectl run D) Both A and B

Answer: D) Both A and B Explanation: Both kubectl create and kubectl apply can create
resources from YAML files.

38. What is the difference between kubectl create and kubectl apply?

A) No difference B) create is imperative, apply is declarative C) apply is faster D) create


supports more resources

Answer: B) create is imperative, apply is declarative Explanation: create is imperative


(one-time), apply is declarative (can be rerun safely).

39. What is a ConfigMap?

A) Configuration data storage B) Secret data storage C) Image configuration D) Network


configuration
Answer: A) Configuration data storage Explanation: ConfigMap stores non-confidential
configuration data in key-value pairs.

40. What is the difference between ConfigMap and Secret?

A) No difference B) Secret stores sensitive data encoded in base64 C) ConfigMap is


encrypted D) Secret is faster

Answer: B) Secret stores sensitive data encoded in base64 Explanation: Secrets store
sensitive data (passwords, tokens) encoded in base64.

41. What is a PersistentVolume (PV)?

A) Temporary storage B) Storage resource in cluster independent of Pod lifecycle C)


Container volume D) Network storage

Answer: B) Storage resource in cluster independent of Pod lifecycle Explanation: PV is


cluster-level storage resource that exists independently of Pod lifecycle.

42. What is a PersistentVolumeClaim (PVC)?

A) Storage allocation B) Request for storage by user C) Volume mount D) Storage class

Answer: B) Request for storage by user Explanation: PVC is a request for storage
resources by a user/Pod.

43. Which component schedules Pods to nodes?

A) kubelet B) kube-proxy C) Scheduler D) Controller Manager

Answer: C) Scheduler Explanation: Scheduler assigns Pods to appropriate nodes based on


resource requirements.

44. What is kube-proxy?

A) API gateway B) Network proxy that maintains network rules C) Container runtime D)
Storage manager

Answer: B) Network proxy that maintains network rules Explanation: kube-proxy


maintains network rules for service communication.

45. What is a DaemonSet?

A) System daemon B) Ensures Pod runs on all or selected nodes C) Database cluster D)
Monitoring system

Answer: B) Ensures Pod runs on all or selected nodes Explanation: DaemonSet ensures a
copy of Pod runs on all (or selected) nodes.
46. What is the purpose of liveness probe?

A) Check if Pod is ready B) Check if container is running C) Monitor resource usage D)


Validate configuration

Answer: B) Check if container is running Explanation: Liveness probe checks if container


is running and restarts if failed.

47. What is the purpose of readiness probe?

A) Check if container is ready to serve traffic B) Check if container is running C) Monitor


CPU usage D) Validate network

Answer: A) Check if container is ready to serve traffic Explanation: Readiness probe


determines if container is ready to receive traffic.

48. What is Helm?

A) Container runtime B) Package manager for Kubernetes C) Monitoring tool D) CI/CD tool

Answer: B) Package manager for Kubernetes Explanation: Helm is package manager for
Kubernetes that manages charts (application packages).

49. What is a Helm Chart?

A) Monitoring dashboard B) Package of pre-configured Kubernetes resources C) Network


diagram D) Performance metric

Answer: B) Package of pre-configured Kubernetes resources Explanation: Helm Chart is


collection of files that describe related set of Kubernetes resources.

50. What is the difference between ReplicaSet and Deployment?

A) No difference B) Deployment manages ReplicaSets and provides rolling updates C)


ReplicaSet is newer D) Deployment is simpler

Answer: B) Deployment manages ReplicaSets and provides rolling updates


Explanation: Deployment provides higher-level management over ReplicaSets with rolling
updates capability.

51. What is a Job in Kubernetes?

A) Long-running service B) Runs Pods to completion for batch workloads C) Network


configuration D) Storage allocation

Answer: B) Runs Pods to completion for batch workloads Explanation: Job creates one
or more Pods and ensures specified number complete successfully.

52. What is a CronJob?


A) System cron B) Job that runs on schedule C) Continuous deployment D) Monitoring job

Answer: B) Job that runs on schedule Explanation: CronJob creates Jobs on time-based
schedule using cron format.

53. Which command scales a deployment?

A) kubectl scale B) kubectl resize C) kubectl expand D) kubectl grow

Answer: A) kubectl scale Explanation: kubectl scale changes number of replicas in


deployment/replicaset.

54. What is Horizontal Pod Autoscaler (HPA)?

A) Manual scaling B) Automatically scales Pods based on CPU/memory usage C) Node


scaling D) Storage scaling

Answer: B) Automatically scales Pods based on CPU/memory usage Explanation: HPA


automatically scales number of Pods based on observed CPU/memory utilization.

55. What is a Vertical Pod Autoscaler (VPA)?

A) Scales Pod replicas B) Adjusts CPU/memory requests and limits C) Scales nodes D)
Scales storage

Answer: B) Adjusts CPU/memory requests and limits Explanation: VPA automatically


adjusts CPU and memory requests/limits for containers.

56. What is Cluster Autoscaler?

A) Scales Pods B) Scales worker nodes in cluster C) Scales services D) Scales storage

Answer: B) Scales worker nodes in cluster Explanation: Cluster Autoscaler automatically


adjusts size of cluster by adding/removing nodes.

57. What is an InitContainer?

A) First container in Pod B) Container that runs before app containers C) System container
D) Backup container

Answer: B) Container that runs before app containers Explanation: InitContainers run to
completion before app containers start.

58. What is a Sidecar container?

A) Backup container B) Helper container that runs alongside main container C) Init container
D) System container
Answer: B) Helper container that runs alongside main container Explanation: Sidecar
containers extend functionality of main container (logging, monitoring, etc.).

59. What is RBAC in Kubernetes?

A) Resource allocation B) Role-Based Access Control C) Network policy D) Storage


management

Answer: B) Role-Based Access Control Explanation: RBAC regulates access to resources


based on roles assigned to users.

60. What is a ServiceAccount?

A) User account B) Identity for processes running in Pods C) Admin account D) Service
configuration

Answer: B) Identity for processes running in Pods Explanation: ServiceAccount provides


identity for processes running in Pods to access Kubernetes API.

61. What is kubectl?

A) Cluster component B) Command-line tool for interacting with Kubernetes C) Container


runtime D) Package manager

Answer: B) Command-line tool for interacting with Kubernetes Explanation: kubectl is


CLI tool for running commands against Kubernetes clusters.

62. Which command shows cluster information?

A) kubectl info B) kubectl cluster-info C) kubectl status D) kubectl describe

Answer: B) kubectl cluster-info Explanation: kubectl cluster-info displays cluster


information including API server address.

63. What is Minikube?

A) Production cluster B) Local Kubernetes cluster for development C) Cloud service D)


Container registry

Answer: B) Local Kubernetes cluster for development Explanation: Minikube runs


single-node Kubernetes cluster locally for development/testing.

64. What is kubeadm?

A) Container runtime B) Tool to bootstrap Kubernetes cluster C) Package manager D)


Monitoring tool

Answer: B) Tool to bootstrap Kubernetes cluster Explanation: kubeadm is tool for


bootstrapping minimum viable Kubernetes cluster.
65. What is the purpose of labels in Kubernetes?

A) Name resources B) Organize and select resources C) Secure resources D) Monitor


resources

Answer: B) Organize and select resources Explanation: Labels are key-value pairs used to
organize and select subsets of objects.

66. What are selectors in Kubernetes?

A) Resource filters B) Used to identify set of objects based on labels C) Network rules D)
Storage policies

Answer: B) Used to identify set of objects based on labels Explanation: Selectors identify
set of objects based on their labels.

67. What is a NetworkPolicy?

A) Network configuration B) Controls traffic flow between Pods C) Load balancer rules D)
DNS policy

Answer: B) Controls traffic flow between Pods Explanation: NetworkPolicy controls


traffic flow at IP address or port level between Pods.

68. What is Ingress Controller?

A) Traffic controller B) Implements Ingress rules C) Load balancer D) API gateway

Answer: B) Implements Ingress rules Explanation: Ingress Controller watches for Ingress
resources and implements the rules.

69. What is the difference between Service and Ingress?

A) No difference B) Service for internal routing, Ingress for external HTTP/HTTPS routing
C) Ingress is older D) Service is more powerful

Answer: B) Service for internal routing, Ingress for external HTTP/HTTPS routing
Explanation: Services provide internal networking, Ingress handles external HTTP/HTTPS
routing.

70. What is kubectl apply vs kubectl create?

A) Same functionality B) apply is declarative and idempotent, create is imperative C) create


is faster D) apply only works with deployments

Answer: B) apply is declarative and idempotent, create is imperative Explanation:


kubectl apply manages resources declaratively and can be safely rerun.

71. What is a Rolling Update?


A) Manual update B) Gradual replacement of old Pods with new ones C) Immediate update
D) Backup update

Answer: B) Gradual replacement of old Pods with new ones Explanation: Rolling update
gradually replaces old Pods with new ones maintaining availability.

72. What is Blue-Green Deployment?

A) Color coding B) Two identical production environments for zero-downtime deployments


C) Security strategy D) Monitoring approach

Answer: B) Two identical production environments for zero-downtime deployments


Explanation: Blue-Green deployment uses two identical environments to achieve zero-
downtime deployments.

73. What is Canary Deployment?

A) Monitoring strategy B) Gradual rollout to subset of users C) Backup strategy D) Security


measure

Answer: B) Gradual rollout to subset of users Explanation: Canary deployment releases


new version to small subset of users before full rollout.

74. What is kubectl port-forward used for?

A) Network configuration B) Forward local port to Pod port for debugging C) Service
creation D) Load balancing

Answer: B) Forward local port to Pod port for debugging Explanation: kubectl port-
forward creates tunnel from local machine to Pod for debugging/testing.

75. What is kubectl logs used for?

A) System logs B) View container logs from Pods C) Cluster logs D) Network logs

Answer: B) View container logs from Pods Explanation: kubectl logs displays logs from
containers in Pods for debugging.

ADVANCED CONCEPTS
76. What is Custom Resource Definition (CRD)?

A) Default resource B) Extends Kubernetes API with custom resources C) Configuration file
D) Storage definition

Answer: B) Extends Kubernetes API with custom resources Explanation: CRD allows
you to define custom resources and extend Kubernetes API.
77. What is an Operator in Kubernetes?

A) Cluster administrator B) Application-specific controller that extends Kubernetes API C)


System process D) Network operator

Answer: B) Application-specific controller that extends Kubernetes API Explanation:


Operator is method of packaging, deploying and managing Kubernetes application using
custom resources.

78. What is Istio?

A) Container runtime B) Service mesh platform C) Package manager D) Monitoring tool

Answer: B) Service mesh platform Explanation: Istio is open-source service mesh that
provides traffic management, security, and observability.

79. What is a Service Mesh?

A) Network topology B) Infrastructure layer for service-to-service communication C) Load


balancer D) API gateway

Answer: B) Infrastructure layer for service-to-service communication Explanation:


Service mesh provides communication infrastructure between services with features like load
balancing, encryption, and observability.

80. What is kubectl exec used for?

A) Execute deployment B) Execute commands inside running container C) Execute service


D) Execute cluster

Answer: B) Execute commands inside running container Explanation: kubectl exec runs
commands inside containers in Pods for debugging and maintenance.

Key Interview Tips:


1. Docker Fundamentals: Focus on containerization concepts, Dockerfile instructions,
and container lifecycle management.
2. Kubernetes Architecture: Understand master/worker node components and their
responsibilities.
3. Pod Management: Know Pod lifecycle, multi-container pods, init containers, and
sidecar patterns.
4. Networking: Understand Services, Ingress, NetworkPolicies, and how Pods
communicate.
5. Storage: Grasp PV, PVC, StorageClasses, and persistent storage concepts.
6. Scaling & Updates: Master HPA, VPA, rolling updates, and deployment strategies.
7. Security: Understand RBAC, ServiceAccounts, Secrets, and security best practices.
8. Troubleshooting: Know common kubectl commands for debugging and log analysis.
9. Advanced Topics: Familiarize with CRDs, Operators, and service mesh concepts for
senior roles.
10. Best Practices: Understand resource limits, health checks, and production-ready
configurations.

You might also like