0% found this document useful (0 votes)
39 views18 pages

DevOps Interview Questions - Answers

Uploaded by

dineshp2522
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)
39 views18 pages

DevOps Interview Questions - Answers

Uploaded by

dineshp2522
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/ 18

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

 Setup & Configuration


Before you install Docker Engine for the first time on a new host machine, you need to set
up the Docker repository. Afterward, you can install and update Docker from the repository.

# Add Docker's official GPG key:


sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL
https://download.docker.com/linux/ubuntu/gpg -o
/etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to apt sources:


echo \
"deb [arch=$(dpkg --print-architecture) signed-
by=/etc/apt/keyrings/docker.asc]
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable"
| \

sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


sudo apt-get update
To install latest version of Docker packages

sudo apt-get install docker-ce docker-ce-cli containerd.io


docker-buildx-plugin docker-compose-plugin
docker -v

Verify that the Docker Engine installation is successful by running the hello-world image

sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container
runs, it prints a confirmation message and exits.

You have now successfully installed and started Docker Engine.

Configure Docker to start on boot with systemd

sudo systemctl enable docker.service


sudo systemctl enable containerd.service

Run sample docker container

docker run -it --rm -d -p 8080:80 --name web nginx


Ref:
https://docs.docker.com/engine/install/ubuntu/
https://www.docker.com/blog/how-to-use-the-official-nginx-docker-image/
https://docs.docker.com/get-started/

 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:

# Use the official Nginx base image


FROM nginx:latest

# Set environment variables


ENV NGINX_VERSION=latest \
NGINX_PORT=80 \
NGINX_WORKDIR=/usr/share/nginx/html

# Set the working directory


WORKDIR $NGINX_WORKDIR

# Copy custom configuration file


COPY nginx.conf /etc/nginx/nginx.conf

# Copy static files to serve


COPY index.html $NGINX_WORKDIR/index.html

# Install nodejs package


RUN apt-get update && apt-get install -y \
nodejs \
npm \
&& npm install

# Set the local volume to the container


VOLUME /var/lib/mysql

# Expose port
EXPOSE $NGINX_PORT
# Define the default command to run when the container starts
ENTRYPOINT ["node", "app.js"]

$ docker build

You can name your image as well.


$ docker build -t my-image

If your Dockerfile is placed in another path,


$ docker build -f /path/to/a/Dockerfile .

To check images on the system


$ docker image ls

 Docker Command Difference

 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/

 Docker Multi Stage Builds


We can use multi stage builds in Docker to optimize docker image size, faster deployment etc.

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.

 Step To Create Jenkins Container

 Create Jenkins Docker Container


# docker pull jenkins/jenkins:lts
# docker run -d -p 8080:8080 -v jenkins_home:/var/jenkins_home --name
jenkins_container jenkins/jenkins:lts
# docker logs jenkins_container
# create Nginx web server container with custom index page

# Use the official Nginx base image


FROM nginx:latest
# Set environment variables
ENV NGINX_VERSION=latest \
NGINX_PORT=80 \
NGINX_WORKDIR=/usr/share/nginx/html
# Set the working directory
WORKDIR $NGINX_WORKDIR

# Copy custom configuration file


COPY nginx.conf /etc/nginx/nginx.conf
# Copy static files to serve
COPY index.html $NGINX_WORKDIR/index.html
# Expose port
EXPOSE $NGINX_PORT
# Build Image

docker build -t <image_name> .


for example - docker build -t demo-docker-image .

Check docker images


- docker image ls

- Tag docker image for push


# docker tag demo-docker-image namdevnmr/first-image
- Push docker image now
docker push namdevnmr/first-image

Login to docker hub and check image pushed or not


https://hub.docker.com/

docker tag demo-image namdevnmr/first-image:1


docker push namdevnmr/first-image:1
# Remove Docker Container
docker ps -a
docker rm <container_id>

# docker image ls
# docker rmi <image_name>

 Docker Troubleshooting Commands

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 networks, aiding in identifying network-related problems or misconfigurations.


docker network ls

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

 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
 EKS Cluster Setup
Pre-requisites
 About Author

 Name : Namdev Rathod


 GitHub Projects : https://github.com/namdev-rathod
 YouTube : https://youtube.com/@namdev.devops
 Topmate : https://topmate.io/namdevrathod
 Email : support@devopswithnamdev.com
 WhatsApp : +91 7249 0590 06
 Website : https://devopswithnamdev.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy