Docker
1. What is Docker, and how is it different from Virtual Machines?
Answer: Docker uses containers to run applications and their dependencies in
isolated environments. Unlike VMs, Docker containers share the host OS kernel,
making them lightweight and faster.
2. What is a Dockerfile, and why is it used?
Answer: A Dockerfile is a script containing a series of instructions to build a Docker
image. It automates the image creation process.
3. What is the difference between a Docker image and a container?
Answer: An image is a blueprint for creating containers. A container is a running
instance of an image.
4. How do you expose ports in a Docker container?
Answer: Use the EXPOSE directive in a Dockerfile and the -p flag during docker run. For
example: docker run -p 8080:80 image_name.
5. What is Docker Compose?
Answer: Docker Compose is a tool to define and manage multi-container
applications using a docker-compose.yml file.
6. How do you manage data in Docker containers?
Answer: Use volumes (docker volume create) or bind mounts to persist data outside the
container.
7. What is a multi-stage build in Docker?
Answer: A multi-stage build allows you to use multiple FROM statements in a
Dockerfile to optimize image size by copying only required artifacts into the final
stage.
8. How do you debug a Docker container?
Answer: Use docker logs, docker exec, or attach a shell using docker exec -it <container_id>
/bin/bash.
9. What is the difference between COPY and ADD in Dockerfile?
Answer: COPY only copies files, while ADD can also handle remote URLs and auto-
extract compressed files.
10. What are Docker namespaces and cgroups?
Answer: Namespaces provide isolation for containers, while cgroups control
resource allocation like CPU and memory.
Kubernetes (K8s)
1. What is Kubernetes, and what are its main components?
Answer: Kubernetes is a container orchestration tool. Key components include the
API Server, Scheduler, Controller Manager, Kubelet, and etcd.
2. What is a Pod in Kubernetes?
Answer: A Pod is the smallest deployable unit in Kubernetes, encapsulating
containers and their shared resources.
3. What are Services in Kubernetes?
Answer: Services expose a set of Pods as a network service. Types include ClusterIP,
NodePort, and LoadBalancer.
4. What is a ConfigMap?
Answer: A ConfigMap stores configuration data in key-value pairs, allowing Pods to
use configuration without hardcoding.
5. How do you scale applications in Kubernetes?
Answer: Use the kubectl scale command or define an HPA (Horizontal Pod Autoscaler).
6. What is the difference between ReplicaSet and Deployment?
Answer: A ReplicaSet ensures a specified number of Pod replicas, while a
Deployment provides declarative updates for Pods and ReplicaSets.
7. What is a DaemonSet?
Answer: A DaemonSet ensures that a copy of a Pod runs on all or specific nodes.
8. How does Kubernetes handle node failures?
Answer: Kubernetes automatically reschedules Pods from failed nodes to healthy
ones if resources allow.
9. What is a PersistentVolume (PV) in Kubernetes?
Answer: A PV is a piece of storage provisioned in the cluster. It is used to retain data
beyond the lifecycle of Pods.
10. What is the role of etcd in Kubernetes?
Answer: etcd is a distributed key-value store that Kubernetes uses to store cluster
state and configuration data.
Jenkins
1. What is Jenkins, and what is its role in CI/CD?
Answer: Jenkins automates the building, testing, and deployment of applications in a
CI/CD pipeline.
2. What are Jenkins pipelines?
Answer: Pipelines are scripts (written in Groovy) that define workflows for
automating CI/CD tasks.
3. What is a Jenkins agent?
Answer: Agents (nodes) are machines that execute tasks defined in the Jenkins
controller.
4. How do you install plugins in Jenkins?
Answer: Use the Jenkins dashboard, navigate to "Manage Jenkins" → "Manage
Plugins," and install plugins.
5. What are Declarative and Scripted Pipelines?
Answer: Declarative pipelines use a structured, predefined syntax, while scripted
pipelines use Groovy for complex logic.
6. How do you secure Jenkins credentials?
Answer: Use the Jenkins Credentials Manager to securely store secrets and use them
in pipelines.
7. What is Blue Ocean in Jenkins?
Answer: Blue Ocean is a modern Jenkins interface for creating and visualizing
pipelines.
8. What is a webhook in Jenkins?
Answer: A webhook triggers Jenkins builds automatically on repository events like
commits or merges.
9. How can you implement parallelism in Jenkins pipelines?
Answer: Use the parallel block in declarative pipelines to run tasks simultaneously.
10. How do you integrate Jenkins with Docker?
Answer: Install the Docker plugin, configure the Docker daemon, and use Docker
commands in pipelines.
Shell Scripting
1. What is a shell script?
Answer: A shell script is a text file containing a sequence of commands for the shell
to execute.
2. How do you make a script executable?
Answer: Use chmod +x script.sh to make the script executable.
3. What is the purpose of #!/bin/bash at the start of a script?
Answer: It specifies the interpreter to be used for the script.
4. How do you read user input in a shell script?
Answer: Use the read command. Example: read name; echo "Hello, $name"
5. What is the difference between $* and $@?
Answer: $* treats all arguments as a single word, while $@ treats each argument as a
separate word.
6. What are exit codes in shell scripting?
Answer: Exit codes indicate the success (0) or failure (non-zero) of a command or
script.
7. How do you schedule a script to run periodically?
Answer: Use cron jobs. Edit the crontab using crontab -e.
8. What is the purpose of set -e in a script?
Answer: It causes the script to exit immediately if a command returns a non-zero exit
code.
9. Write a script to find all .txt files in a directory and count lines in each.
Answer:
10. for file in *.txt; do
11. echo "$file: $(wc -l < "$file") lines"
12. done
13. How do you debug a shell script?
Answer: Use bash -x script.sh or include set -x in the script.
Ansible
1. What is Ansible, and how does it work?
Answer: Ansible is an agentless automation tool that uses SSH to manage and
configure systems.
2. What is the difference between an Inventory file and a Playbook?
Answer: An Inventory file lists target hosts, while a Playbook defines tasks to
perform on those hosts.
3. What are Ansible Modules?
Answer: Modules are reusable scripts for specific tasks, like copy, yum, or service.
4. What is the use of Roles in Ansible?
Answer: Roles organize tasks, variables, files, and templates into reusable units.
5. How do you test an Ansible Playbook?
Answer: Use --check mode to perform a dry run without making changes.
6. What is the difference between when and delegate_to in Ansible?
Answer: when adds conditional logic to tasks, while delegate_to runs tasks on a
different host.
7. What is the purpose of ansible-galaxy?
Answer: It is used to create and manage Ansible roles and download reusable roles
from the Galaxy repository.
8. How do you handle dynamic inventory in Ansible?
Answer: Use inventory scripts or plugins to dynamically generate inventory from
external sources.
9. What are Ansible Facts?
Answer: Facts are system variables automatically gathered by Ansible, such as OS, IP,
and memory.
10. How do you execute a single Ansible module on a host?
Answer: Use ansible <host> -m <module> -a "<arguments>".
Linux
1. What are Linux runlevels?
Answer: Runlevels are predefined states of a Linux system, such as single-user mode
(1) or multi-user with GUI (5).
2. What is the difference between hard link and soft link?
Answer: Hard links point to the same inode, while soft links are shortcuts pointing to
the file.
3. How do you check disk usage in Linux?
Answer: Use the df and du commands.
4. How do you list open ports in Linux?
Answer: Use netstat -tuln or ss -tuln.
5. What is the purpose of the chown command?
Answer: It changes the ownership of files or directories.
6. What is the difference between grep and awk?
Answer: grep searches for patterns in files, while awk is a more powerful tool for
pattern scanning and text processing.
7. How do you find a file in Linux?
Answer: Use the find command, e.g., find / -name file.txt.
8. What are Linux system logs, and where are they stored?
Answer: Logs track system events and are stored in /var/log.
9. What is cron in Linux?
Answer: cron is a scheduler for running repetitive tasks.
10. What is the purpose of umask?
Answer: umask sets default file permissions for newly created files.
Python
1. What are Python's main uses in DevOps?
Answer: Automation, configuration management, API interaction, and scripting.
2. What is the difference between a list and a tuple in Python?
Answer: Lists are mutable, while tuples are immutable.
3. How do you handle exceptions in Python?
Answer: Use try...except blocks.
4. What is a Python virtual environment?
Answer: It isolates project dependencies.
5. How do you execute shell commands in Python?
Answer: Use the subprocess module.
6. What are Python decorators?
Answer: Decorators modify the behavior of functions or classes.
7. How do you read a file in Python?
Answer:
8. with open('file.txt', 'r') as file:
9. content = file.read()
10. What is the os module used for?
Answer: It provides functions to interact with the operating system.
11. How do you install Python packages?
Answer: Use pip install <package>.
12. What is the purpose of argparse in Python?
Answer: It parses command-line arguments.
Git
1. What is Git?
Answer: A distributed version control system.
2. How do you clone a repository?
Answer: Use git clone <repo_url>.
3. What is the difference between git fetch and git pull?
Answer: git fetch downloads changes, while git pull also merges them.
4. How do you resolve a merge conflict?
Answer: Edit the conflicting files, stage them, and commit.
5. What is Git stash?
Answer: It temporarily saves changes.
6. How do you create a new branch in Git?
Answer: Use git branch <branch_name>.
7. What is the difference between rebase and merge?
Answer: merge combines histories, while rebase rewrites commits.
8. How do you check Git logs?
Answer: Use git log.
9. How do you delete a branch?
Answer: Use git branch -d <branch_name>.
10. What is Git cherry-pick?
Answer: It applies a specific commit to the current branch.