DevOps Interview Questions - Answers
DevOps Interview Questions - Answers
AWS
Linux
Git
GitHub/Jenkins/GitLab CICD
Monitoring
Architecture
Cost Optimization
Security
High Availability / Failover
Real Time Troubleshootings
Terraform
Docker
What is Docker?
Architecture of Docker
Setup & Configuration
Docker Commands
Docker File
Docker Multi Stage Builds
Docker Interview Questions
Docker Troubleshooting Commands
Kubernetes
What is Kubernetes?
EKS Cluster Setup
Kubernetes Architecture
Services
Pod Deployments
Helm Chart
Logs Monitoring
Services
o NodePort
o Load balancer
o Cluster IP
o External Name
o Headless
o Ingress
Controller
o Deployment
o Daemon set
o Stateful set
o Replica set
Liveness
Readiness
Namespace
Secrets
Real Time Troubleshootings
Docker
What is Docker?
Docker is a platform for developing, shipping, and running applications using
containerization technology. It allows developers to package their applications and
dependencies into lightweight, portable containers that can run consistently across
different environments. Docker simplifies the process of building, deploying, and
scaling applications by isolating them from the underlying infrastructure, enabling
faster and more reliable software delivery.
Architecture of Docker
Docker Daemon
Docker daemon runs on the host operating system. It is responsible for running
containers to manage docker services. Docker daemon communicates with other
daemons. It offers various Docker objects such as images, containers, networking,
and storage.
Docker Host
Docker Host is used to provide an environment to execute and run applications. It
contains the docker daemon, images, containers, networks, and storage.
Docker Registry
Docker Registry manages and stores the Docker images.
o Public Registry – Docker Hub, Google CR & AWS ECR
o Private Registry – GitLab CR, Azure CR & JFrog
Verify that the Docker Engine installation is successful by running the hello-world image
This command downloads a test image and runs it in a container. When the container
runs, it prints a confirmation message and exits.
Docker File
Dockerfile is a text file that contains a list of commands (instructions), which describes
how a Docker image is built based on them.
An example of Dockerfile:
# Expose port
EXPOSE $NGINX_PORT
# Define the default command to run when the container starts
ENTRYPOINT ["node", "app.js"]
$ docker build
COPY vs ADD
Both commands serve a similar purpose, to copy files into the image.
COPY - let you copy files and directories from the host.
ADD - does the same. Additionally it lets you use URL location and unzip
files into image.
ENTRYPOINT vs. CMD
CMD - allows you to set a default command which will be executed only when
you run a container without specifying a command. If a Docker container
runs with a command, the default command will be ignored.
ENTRYPOINT - allows you to configure a container that will run as an
executable. ENTRYPOINT command and parameters are not ignored when
Docker container runs with command line parameters.
Ref: https://www.geeksforgeeks.org/what-is-dockerfile-syntax/
https://docs.docker.com/reference/dockerfile/
https://www.geeksforgeeks.org/what-is-dockerfile/
Docker Commands
Below are some of the important docker commands
Ref:
https://www.mygreatlearning.com/blog/top-essential-docker-commands/
https://www.geeksforgeeks.org/docker-instruction-commands/?ref=lbp
https://docs.docker.com/get-started/
Docker Compose
Docker Compose is a tool for defining and running multi-container applications
Ref: https://www.simplilearn.com/tutorials/docker-tutorial/docker-compose
Docker Swarm
Docker Swarm is an orchestration management tool that runs on Docker applications. It
helps end-users in creating and deploying a cluster of Docker nodes.
Ref:
- https://www.simplilearn.com/tutorials/docker-tutorial/docker-swarm
- https://docs.docker.com/engine/swarm/swarm-tutorial/
- https://www.sumologic.com/glossary/docker-swarm/
Ref:
- https://dev.to/pavanbelagatti/what-are-multi-stage-docker-builds-1mi9
- https://docs.docker.com/build/guide/multi-stage/
- https://earthly.dev/blog/docker-multistage/
- https://www.harness.io/blog/how-to-create-multi-stage-docker-builds-with-harness-continuous-delivery
Docker Container Status
Created: The container has been created but not yet started.
Restarting: The container is restarting, either due to a failure or a manual
restart command.
Running: The container is up and running, executing its defined tasks or
processes.
Paused: The container's execution has been paused, suspending all processes
within the container.
Exited: The container has stopped running, either because it has completed its
task or due to an error. You can check the exit code to determine the reason
for the exit.
Removing: The container is in the process of being removed or deleted from
the system.
Unknown: The status of the container cannot be determined, often due to an
error or communication issue with the Docker daemon.
# docker image ls
# docker rmi <image_name>
Displays the logs of a specific container, useful for debugging errors or issues.
docker logs [container_id]
Provides detailed information about a container, including its configuration and networking details.
docker inspect [container_id]
Monitors real-time events from Docker, helpful for tracking container lifecycle events or errors.
docker events
Displays the running processes inside a container, aiding in diagnosing performance issues or unexpected
behavior.
docker top [container_id]
Shows resource usage statistics for a container, including CPU, memory, and network usage.
docker stats [container_id]
Opens an interactive shell inside a running container, allowing direct access for troubleshooting or
debugging.
docker exec -it [container_id] /bin/bash
Lists the ports mapped to a container, aiding in verifying port bindings and networking configurations.
docker port [container_id]
Provides detailed information about a Docker network, including connected containers and their IP
addresses.
docker network inspect [network_id]
Shows the file system changes made within a container since it was started, helpful for identifying
modifications.
docker diff [container_id]
Displays information about disk usage by Docker, including images, containers, and volumes, useful for
identifying storage issues.
docker system df
Lists recent Docker events, providing insights into system-level changes or errors.
docker system events
Shows detailed information about the Docker installation, including version, configuration, and supported
features.
docker info
Displays the Docker version information, helpful for checking compatibility or troubleshooting version-
related issues.
docker version
Lists all Docker images available locally, useful for checking if required images are present.
docker image ls
Displays the history of an image, showing how it was built and its layers, helpful for identifying issues in the
image build process.
docker image history [image_name]
Lists all Docker volumes, aiding in identifying volume-related problems or checking if required volumes exist.
docker volume ls
Removes unused data, including stopped containers, dangling images, and unused networks or volumes,
helping to reclaim disk space and clean up the system.
docker system prune
Displays logs for a specific service defined in a docker-compose.yml file, useful for troubleshooting multi-
container applications.
docker-compose logs [service_name]
Kubernetes
Kubernetes
What is Kubernetes?
Kubernetes is an open-source Container Management tool that automates container
deployment, container scaling, descaling, and container load balancing (also called a
container orchestration tool). It is written in Go language.
https://www.geeksforgeeks.org/kubernetes-node/?ref=lbp
https://www.geeksforgeeks.org/kubernetes-nodeport-service/?ref=lbp