Docker – Basic Questions
1. What is Docker and why is it used?
: Docker is an open source platform for deploying, shipping and maintaining
application in containers.
It's a tool that lets you package your code, your libraries, and your settings into a
single file called an Image. When you run that file, it becomes a Container
Docker is used because of it’s Efficiency and Speed, platform independent,
Lightweight, Scalability.
2. What is a Docker image?
A Docker Image is a lightweight, standalone, and executable software
package that includes everything needed to run an application: the code, a
runtime, system tools, libraries, and settings.
3. What is a Docker container?
A Docker container is a standardized, isolated software package that bundles an application and
everything it needs to run—code, runtime, system tools, libraries, and settings.
4. What is a Dockerfile?
A Dockerfile is a simple text file that contains a script of instructions
for building a Docker image
5. What is the difference between Docker image and container?
An image is a snapshot of an environment, while
a container runs the software using the Image.
6. What are Docker layers?
7. What is Docker Hub?
Docker Hub is a cloud-based repository service where developers and
teams can push (upload) and pull (download) Docker container images
anytime via the internet.
8. What is the purpose of docker run?
docker run is a command used to start a new container from a Docker image
9. What is a Docker volume?
Docker volumes are file systems that are mounted on Docker containers to
preserve the data generated by the container outside the container's
filesystem, in a persistent and reusable location managed by Docker.
Even if the container is stopped, removed, or rebuilt, the data in the volume
remains intact.
10. What is the difference between COPY and ADD in Dockerfile?
Copy: copies local files to container, used locally
Add: Copies the files from URL to container
11. What is the purpose of CMD in Dockerfile?
CMD is used for running the linux commands while container creation. But
CMD commands get ignored if you provide arguments in your Docker
run command.
12. What is the purpose of ENTRYPOINT in Dockerfile?
An ENTRYPOINT is used for running the linux commands while container creation,
but unlike CMD, does not ignore additional parameters that you specify in
your Docker run command
13. What is Docker Compose?
Docker Compose is an orchestration tool for defining and running multi-
container Docker applications.
14. What is the difference between Docker Compose and Kubernetes?
High availability is not possible in Docker Compose.
Docker Compose is ideal for setting up multi-container Docker applications on a single
server, while Kubernetes orchestrats containers across multiple machines
Self healing is not available in Docker
Docker we use only 1 Yaml and in Kubernetes we’ve multiple Yamla
15. What is a base image?
This is the foundational layer of your image, specified by
the FROM instruction in a Dockerfile. It can be a minimal operating system
like alpine, a programming language runtime like python:3.9-slim, or an
application like nginx.
16. What are common Dockerfile best practices?
Use Small & Official Images: Start with lightweight, official images to keep images
small.
Use Multi-Stage Builds: Separate build tools from the final app, allowing you to
copy only necessary artifacts into the final image, drastically reducing size.
Order Commands for Caching: Place commands that change less frequently (e.g.,
installing dependencies) before commands that change often (e.g., copying source
code).
Combine RUN Commands: Use && to combine multiple commands into
one RUN layer to prevent extra, bloated layers.
Use .dockerignore : Create a .dockerignore file to prevent
copying node_modules , .git , or large, unnecessary local files into the container.
Run as Non-Root: Avoid running containers as root to enhance security.
Avoid latest Tag: Pin your base image to a specific version (e.g., python:3.11-
slim ) for stability and reproducibility.
Use COPY Over ADD : Use COPY for clarity unless you specifically need to extract a
local tar file.
Clean Up After Install: If installing packages, remove temporary files within the
same RUN command to reduce image size (e.g., rm -rf /var/lib/apt/lists/* ).
Docker – Intermediate Questions
1. How do multi-stage builds work in Docker?
Multi-stage Docker builds provide an efficient way to create optimized
Docker images by separating the build environment from the runtime
environment. This results in smaller, more secure, and easier-to-
maintain images.
A multi-stage Dockerfile consists of multiple FROM statements, each
representing a separate stage with its own base image and
instructions
2. How do you optimize the size of a Docker image?
3. How does Docker networking work?
4. What is the difference between bridge, host, and overlay networks?
5. How do you inspect logs of a Docker container?
6. How do you monitor running Docker containers?
7. How do you persist data across container restarts?
8. What is the difference between bind mounts and volumes?
9. How does Docker handle container isolation?
10. What are common security risks in Docker?
11. Explain the Docker build cache.
12. How does Docker differ from a virtual machine?
Kubernetes – Basic Questions
1. What is Kubernetes?
2. What is a Pod in Kubernetes?
3. What is a Deployment?
4. What is a Service in Kubernetes?
5. What are the types of Kubernetes Services?
6. What is a Node?
7. What is a Namespace?
8. What is a ConfigMap?
9. What is a Secret?
10. What is a ReplicaSet?
11. What is a kubelet?
12. What is kubectl?
13. What is the difference between a Pod and a Container?
14. What is ETCD?
15. What is the purpose of kube-proxy?
Kubernetes – Intermediate Questions
1. Explain differences between NodePort, ClusterIP, and LoadBalancer.
2. What is a StatefulSet and where is it used?
3. What is a DaemonSet? Give use cases.
4. What is Ingress and why is it used?
5. What is a ServiceAccount?
6. 11111111
7. What is node affinity and anti-affinity?
8. What is the Horizontal Pod Autoscaler (HPA)?
9. How does Kubernetes perform rolling updates?
10. What is a CronJob?
11. How does the Kubernetes Scheduler work?
12. What happens when a Pod crashes?
13. How do requests and limits work in Kubernetes?
14. What is a sidecar container?
15. What is minikube and when is it useful?