Free practice questions

Technical
Interview questions

Prepare for technical interviews with questions by technology, clear explanations, step-by-step solutions and code you can run.

DevOps questions
50 questions
25
25 concept questions
25
25 coding questions

DevOps technical questions

DevOps Lifecycle, CI/CD Pipelines, Docker, Kubernetes, Terraform, Ansible, Linux & Monitoring
Total 50 Questions
Part A: Core concept & theory questions
Questions 01 to 25 • Theoretical Foundations
25 Concept Questions

DevOps is a way of working where developers and operations teams share responsibility for building, releasing and running software. The goal is to ship changes faster and with fewer failures.

Earlier, developers wrote code and "threw it over the wall" to operations, which caused delays and blame. DevOps removes that wall through shared tools, automation and ownership.

Plan, code, build, test, release, deploy, operate and monitor, then back to plan. It's a loop, because monitoring feedback shapes the next round of work.

Developers merge code into a shared branch often, and every merge triggers an automatic build and test run. Bugs get caught within minutes instead of weeks.

In delivery, every change is ready to release but a person presses the button. In deployment, every change that passes the tests goes to production automatically.

An automated path that takes code from a commit through build, test, security checks and deployment. Each stage must pass before the next one runs.

It records every change to the code so I can see history, compare versions and undo mistakes. Git is distributed, so everyone has a full copy and can work offline.

Git Flow uses long-lived branches like develop and release. GitHub Flow uses short feature branches merged into main. Trunk-based development has everyone commit to main in small steps. Teams doing CI/CD often prefer the last two.

Merge joins two branches and keeps the full history, including a merge commit. Rebase replays my commits on top of another branch for a straight, clean history. I never rebase commits that others already pulled.

Describing servers, networks and databases in files instead of clicking in a console. The files live in Git, so infrastructure is reviewable, repeatable and easy to rebuild.

Terraform mainly provisions infrastructure, like creating VMs and networks, and tracks it in a state file. Ansible mainly configures machines, like installing software and editing files, and doesn't need an agent.

A file where Terraform records what it created, so it can compare it to my code and work out what to change. In teams, it's stored remotely with locking so two people don't change it at once.

Running the same operation many times gives the same result as running it once. It's why I can safely re-run an Ansible playbook or terraform apply.

A lightweight package with an app and everything it needs, which runs the same on any machine. Containers share the host's operating system kernel.

A VM includes a full guest operating system, so it's heavier and slower to start. A container shares the host kernel, so it starts in seconds and uses less memory, but offers less isolation.

An image is a read-only template. A container is a running instance of that image. One image can start many containers.

A text file of instructions for building an image: the base image, files to copy, commands to run and the startup command.

Using several FROM steps in one Dockerfile, so I build the app in one stage and copy only the final result into a small image. It makes images smaller and safer.

A system that runs and manages containers across many machines. It handles scheduling, scaling, self-healing and rolling updates.

A Pod is the smallest unit and holds one or more containers. A Deployment keeps the desired number of Pods running and handles updates. A Service gives Pods a stable address and load balances traffic to them.

Rolling replaces instances a few at a time. Blue-green runs two full environments and switches traffic from old to new. Canary sends a small share of users to the new version first, then increases it if it's healthy.

Monitoring tracks numbers over time, like CPU and error rate. Logging records individual events. Tracing follows one request across many services. Together they make up observability.

An SLI is a measurement, like the percentage of successful requests. An SLO is the target for it, like 99.9%. An SLA is a promise to customers, usually with penalties if missed.

Building security into every stage instead of checking at the end. Examples are dependency scanning, secret detection, image scanning and policy checks inside the pipeline.

Deployment frequency, lead time for changes, change failure rate and time to restore service. They show how fast and how stable a team delivers.

Part B: Coding questions & algorithm solutions
Questions 01 to 25 • Runnable Solution Scripts
25 Coding Questions

Git branch checkout, add, commit and push commands.

DevOps Solution
git checkout -b feature/login-page
git add .
git commit -m "Add login page"
git push -u origin feature/login-page

Use git reset --soft for local undo and git revert for pushed commits.

DevOps Solution
git reset --soft HEAD~1      # local only: undo commit, keep changes staged
git revert <commit-id>       # pushed: creates a new commit that undoes it

Dockerfile instructions with node:20-alpine base image and production npm ci.

DevOps Solution
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

Multi-stage Docker build using golang:1.22 and distroless static runtime.

DevOps Solution
FROM golang:1.22 AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -o /app .

FROM gcr.io/distroless/static
COPY --from=build /app /app
USER nonroot
ENTRYPOINT ["/app"]

List excluded files like node_modules, .git, and .env.

DevOps Solution
node_modules
.git
.env
*.log
Dockerfile

Docker CLI commands for build, run, logs and stop/rm.

DevOps Solution
docker build -t myapp:1.0 .
docker run -d --name web -p 8080:3000 myapp:1.0
docker logs -f web
docker stop web && docker rm web

docker-compose.yaml with service dependencies, environment variables and named volume.

DevOps Solution
services:
  web:
    build: .
    ports:
      - "8080:3000"
    environment:
      DATABASE_URL: postgres://app:secret@db:5432/appdb
    depends_on:
      - db
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: appdb
    volumes:
      - dbdata:/var/lib/postgresql/data

volumes:
  dbdata:

YAML workflow for push/pull_request with Node.js setup and npm test.

DevOps Solution
name: CI
on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm test

Add docker/login-action and docker/build-push-action to GitHub Actions pipeline.

DevOps Solution
publish:
  needs: test
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v4
    - uses: docker/login-action@v3
      with:
        username: ${{ secrets.DOCKER_USER }}
        password: ${{ secrets.DOCKER_TOKEN }}
    - uses: docker/build-push-action@v5
      with:
        push: true
        tags: myuser/myapp:${{ github.sha }}

Declarative Groovy Jenkinsfile pipeline with stages and post failure block.

DevOps Solution
pipeline {
  agent any
  stages {
    stage('Build')  { steps { sh 'npm ci' } }
    stage('Test')   { steps { sh 'npm test' } }
    stage('Deploy') {
      when { branch 'main' }
      steps { sh './deploy.sh' }
    }
  }
  post {
    failure { echo 'Pipeline failed' }
  }
}

Kubernetes Deployment manifest with readinessProbe and CPU/memory requests.

DevOps Solution
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: myuser/myapp:1.0
          ports:
            - containerPort: 3000
          resources:
            requests: { cpu: "100m", memory: "128Mi" }
            limits:   { cpu: "500m", memory: "256Mi" }
          readinessProbe:
            httpGet: { path: /health, port: 3000 }

Kubernetes ClusterIP Service pointing port 80 to targetPort 3000.

DevOps Solution
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 3000

Kubernetes ConfigMap and Secret manifest with envFrom injection.

DevOps Solution
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  LOG_LEVEL: info
---
apiVersion: v1
kind: Secret
metadata:
  name: app-secret
stringData:
  DB_PASSWORD: change-me
---
# Container spec usage:
envFrom:
  - configMapRef: { name: app-config }
  - secretRef:    { name: app-secret }

kubectl CLI commands for apply, get pods, logs and scale.

DevOps Solution
kubectl apply -f deployment.yaml
kubectl get pods
kubectl logs deploy/web
kubectl scale deploy/web --replicas=5

kubectl set image, rollout status, and rollout undo.

DevOps Solution
kubectl set image deploy/web web=myuser/myapp:1.1
kubectl rollout status deploy/web
kubectl rollout undo deploy/web

Kubernetes HPA spec scaling on target 70% CPU average utilization.

DevOps Solution
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: web
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target: { type: Utilization, averageUtilization: 70 }

Terraform HCL configuration for azurerm_resource_group and azurerm_storage_account.

DevOps Solution
provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "rg" {
  name     = "rg-devops-demo"
  location = "Central India"
}

resource "azurerm_storage_account" "sa" {
  name                     = "stdevopsdemo123"
  resource_group_name      = azurerm_resource_group.rg.name
  location                 = azurerm_resource_group.rg.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

Terraform CLI sequence: init, fmt, validate, plan, apply, destroy.

DevOps Solution
terraform init      # download providers
terraform fmt       # tidy formatting
terraform validate  # check syntax
terraform plan      # preview changes
terraform apply     # create or change resources
terraform destroy   # remove everything

Ansible playbook with apt install and service start tasks.

DevOps Solution
- name: Set up web servers
  hosts: webservers
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present
        update_cache: true

    - name: Make sure nginx is running
      ansible.builtin.service:
        name: nginx
        state: started
        enabled: true

# Run command: ansible-playbook -i inventory.ini site.yml

Shell script checking HTTP status code via curl and writing to health.log.

DevOps Solution
#!/bin/bash
URL="https://example.com"
CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL")

if [ "$CODE" -eq 200 ]; then
  echo "$(date) OK $URL" >> health.log
else
  echo "$(date) DOWN $URL (status $CODE)" >> health.log
  exit 1
fi

Bash backup script using tar -czf and find -mtime +7 -delete.

DevOps Solution
#!/bin/bash
SRC="/var/www/html"
DEST="/backups"
mkdir -p "$DEST"

tar -czf "$DEST/site-$(date +%F).tar.gz" "$SRC"
find "$DEST" -name "site-*.tar.gz" -mtime +7 -delete

Crontab schedule entry running daily at 02:00 AM.

DevOps Solution
0 2 * * * /home/user/backup.sh >> /var/log/backup.log 2>&1

Prometheus alert rule configuration with expr up == 0 for 2m.

DevOps Solution
groups:
  - name: availability
    rules:
      - alert: ServiceDown
        expr: up == 0
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "{{ $labels.instance }} is down"

Linux shell one-liners using ps aux --sort=-%mem and df -h.

DevOps Solution
ps aux --sort=-%mem | head -n 6
df -h

Trivy vulnerability security scanning step in CI pipeline.

DevOps Solution
- name: Scan image with Trivy
  uses: aquasecurity/trivy-action@master
  with:
    image-ref: myuser/myapp:${{ github.sha }}
    severity: HIGH,CRITICAL
    exit-code: 1

No Matching Questions Found

Try searching for keywords like "JWT", "Express", "useEffect", "PDO", "GIL", or "schema".

Technical Panel Preparation

Ready to Benchmark Your Technical Skills?

Connect with DigitalXNode expert interviewers for technical mock interviews, domain assessment, and enterprise job placement.

1