Practical DevOps Interview Questions with Answers (2027)

60 practical DevOps interview questions with working answers: Git recovery, Dockerfiles, kubectl debugging, Terraform state, Jenkins and GitHub Actions.

Sep 6, 2025 - 14:34
Nov 9, 2026 - 12:20
 0  139
Practical DevOps Interview Questions with Answers (2027)

Practical DevOps interview questions ask you to do something: write a Dockerfile, fix a failing pipeline, debug a pod, read a Terraform plan or recover a Git mistake. Interviewers judge the command you reach for and the order you check things in. These 60 questions come with working answers you can type, grouped from fresher to senior, with real-time troubleshooting at the end.

For concept-only short lists, see our 20 most common DevOps interview questions; for every topic in one place, use the 200+ DevOps interview questions hub. Tool-specific practice lives in our Docker, Kubernetes scenario and Terraform guides. Commands were checked against official docs (git-scm.com, docs.docker.com, kubernetes.io, developer.hashicorp.com, jenkins.io) in November 2026.

Key takeaways

  • Practical rounds reward a calm order: reproduce, read the error, check what changed, fix, then prevent.
  • Know these by heart: git revert vs git reset, multi-stage Dockerfiles, kubectl describe and kubectl logs --previous, terraform plan and state locking.
  • Pipelines should build once and promote the same artifact through environments.
  • Never put secrets in images, Git or pipeline logs. Use a secret store and short-lived credentials.
  • Have one end-to-end project you can draw: Git push, CI build and test, image to registry, deploy to Kubernetes, monitoring and alerts.

Topics by level

LevelQuestionsTools covered
Freshers1 to 18Linux, Git, Docker basics, CI concepts
2 to 5 years19 to 42Dockerfiles, Kubernetes, Terraform, Jenkins and GitHub Actions, monitoring
Senior43 to 50Pipeline design, release strategy, platform choices
Real-time troubleshooting51 to 60Live debugging problems

Freshers

1. Find which process is listening on port 8080.

ss -tlnp | grep 8080 or sudo lsof -i :8080. Then ps -fp PID to see the full command.

2. Show the last 100 lines of a log and keep following it.

tail -n 100 -f /var/log/app.log. For systemd services: journalctl -u app -n 100 -f.

3. Find files larger than 500 MB under /var.

find /var -type f -size +500M -exec ls -lh {} \; or du -ah /var | sort -rh | head -20.

4. Make a script executable and run it.

chmod +x deploy.sh then ./deploy.sh. Start scripts with #!/usr/bin/env bash and set -euo pipefail so they stop on errors and unset variables.

5. Undo your last commit that is not pushed yet, keeping the changes.

git reset --soft HEAD~1. The changes stay staged. Use --mixed (the default) to keep them unstaged.

6. Undo a commit that is already pushed to a shared branch.

git revert COMMIT_SHA creates a new commit that reverses it. Do not rewrite shared history with reset and force push.

7. What is the difference between merge and rebase?

Merge joins branches with a merge commit and keeps history as it happened. Rebase replays your commits on top of another branch for a linear history. Rebase only your own unpublished branches.

8. You committed to the wrong branch. Fix it.

git switch correct-branch
git cherry-pick COMMIT_SHA
git switch wrong-branch
git reset --hard HEAD~1   # only if not pushed

9. Recover a branch you deleted by mistake.

git reflog shows where HEAD has been. Find the last commit of the branch and run git branch restored SHA.

10. Run an Nginx container on host port 8080.

docker run -d --name web -p 8080:80 nginx. Check with docker ps and curl localhost:8080.

11. Get a shell inside a running container.

docker exec -it web sh (or bash if the image has it). For Kubernetes: kubectl exec -it POD -- sh.

12. What is the difference between an image and a container?

An image is a read-only template of layers. A container is a running instance of an image with its own writable layer.

13. How do you persist data from a container?

Use a named volume (-v data:/var/lib/postgresql/data) or a bind mount. Data in the container's writable layer is lost when the container is removed.

14. What does CI mean in practice?

Every push triggers an automated build and tests, so problems are found within minutes of the change. Developers merge small changes often.

15. What is the difference between continuous delivery and continuous deployment?

Continuous delivery keeps every change releasable, with a manual approval to production. Continuous deployment releases every passing change to production automatically.

16. What is infrastructure as code?

Defining infrastructure in versioned files, applied by tools like Terraform or Ansible, so changes are reviewed and repeatable.

17. How do you check a server's disk, memory and CPU quickly?

df -h, free -h, uptime for load average and top for live processes.

18. Copy a file to a remote server and run a command there.

scp app.tar.gz user@host:/tmp/ then ssh user@host 'tar -xzf /tmp/app.tar.gz -C /opt/app'. Use SSH keys, not passwords.

2 to 5 years

19. Write a multi-stage Dockerfile for a Go service.

FROM golang:1.23 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /out/app ./cmd/app

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

The final image has no compiler or shell, which makes it small and reduces attack surface. Pin the base image versions your team has tested.

20. Why copy dependency files before the rest of the source?

Docker caches each layer. If only source code changes, the dependency download layer is reused and builds are much faster.

21. CMD vs ENTRYPOINT?

ENTRYPOINT sets the executable; CMD gives default arguments that users can override at docker run. Use the exec (JSON array) form so signals reach the process.

22. Write a Docker Compose file for an app and Postgres.

services:
  app:
    build: .
    ports:
      - "8080:8080"
    environment:
      DATABASE_URL: postgres://app:app@db:5432/app
    depends_on:
      db:
        condition: service_healthy
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: app
      POSTGRES_DB: app
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app"]
      interval: 5s
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes:
  pgdata:

Plain-text passwords are fine for a local demo only.

23. Deploy an app to Kubernetes with a Deployment and Service.

kubectl create deployment web --image=nginx:1.27 --replicas=3
kubectl expose deployment web --port=80 --target-port=80
kubectl get pods,svc -l app=web

In real projects, keep the YAML in Git and apply it through a pipeline or GitOps.

24. Roll out a new image and roll back.

kubectl set image deployment/web nginx=nginx:1.27.1
kubectl rollout status deployment/web
kubectl rollout undo deployment/web

25. A pod is Pending. How do you find out why?

kubectl describe pod POD and read Events. Common causes: insufficient CPU or memory, node selectors or taints that no node matches, or a PVC that cannot bind.

26. What are requests and limits?

Requests are what the scheduler reserves for a container. Limits are the maximum; exceeding the memory limit gets the container OOMKilled, and exceeding the CPU limit throttles it.

27. ConfigMap vs Secret?

Both inject configuration. Secrets are for sensitive data, are base64 encoded (not encrypted) by default, and should be protected with encryption at rest and RBAC, or sourced from an external secret store.

28. How do you expose an app over HTTPS in Kubernetes?

Use an Ingress or Gateway API resource with a controller, plus a TLS certificate stored as a Secret, often issued automatically by cert-manager.

29. Write a basic Terraform configuration for an S3 bucket with remote state.

terraform {
  backend "s3" {
    bucket       = "my-tf-state"
    key          = "app/terraform.tfstate"
    region       = "ap-south-1"
    use_lockfile = true
  }
}

resource "aws_s3_bucket" "logs" {
  bucket = "my-app-logs-example"
}

Recent Terraform versions support S3-native state locking with use_lockfile; older setups use a DynamoDB table for locks.

30. What does terraform plan show, and what do you look for?

The changes Terraform will make. Look for unexpected destroys or replacements (-/+), especially on databases and networks, before approving.

31. How do you bring an existing resource under Terraform?

Write the resource block and use an import block (Terraform 1.5+) or terraform import, then run plan until it shows no changes.

32. Two people ran apply at the same time. What protects state?

State locking in the backend. One run gets the lock and the other waits or fails. Never disable locking to get around it.

33. Write a declarative Jenkinsfile with build, test and deploy.

pipeline {
  agent any
  stages {
    stage('Build') { steps { sh 'make build' } }
    stage('Test')  { steps { sh 'make test' } }
    stage('Deploy') {
      when { branch 'main' }
      steps { sh './deploy.sh' }
    }
  }
  post {
    always { junit 'reports/**/*.xml' }
  }
}

34. Write a GitHub Actions workflow that builds and pushes an image.

name: build
on:
  push:
    branches: [main]
permissions:
  contents: read
  packages: write
jobs:
  image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v6
        with:
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

Tagging with the commit SHA makes every image traceable to its source.

35. How do you speed up a slow pipeline?

Cache dependencies and Docker layers, run independent jobs in parallel, run only affected tests where safe, and use larger or self-hosted runners for heavy builds.

36. How should pipelines get cloud credentials?

Through OIDC federation for short-lived credentials, scoped to the repository and branch, instead of long-lived keys stored as secrets.

37. Write an Ansible task to install and start Nginx.

- hosts: web
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.package:
        name: nginx
        state: present
    - name: Start and enable nginx
      ansible.builtin.service:
        name: nginx
        state: started
        enabled: true

38. Terraform vs Ansible: when do you use each?

Terraform provisions infrastructure and tracks it in state. Ansible configures machines and runs procedures. Many teams use Terraform to create VMs and Ansible to configure them.

39. What do you monitor for a web service?

The four golden signals: latency, traffic, errors and saturation. Alert on user-facing symptoms, not on every CPU spike.

40. Write a Prometheus alert for a high error rate.

groups:
  - name: web
    rules:
      - alert: HighErrorRate
        expr: |
          sum(rate(http_requests_total{code=~"5.."}[5m]))
          / sum(rate(http_requests_total[5m])) > 0.05
        for: 10m
        labels:
          severity: page
        annotations:
          summary: "More than 5% of requests are failing"

Validate rule files with promtool check rules. Metric names depend on your instrumentation.

41. How do you centralise logs from Kubernetes?

Run a node-level agent (Fluent Bit, Vector or the OpenTelemetry Collector) as a DaemonSet that ships container logs to Loki, Elasticsearch or a cloud service. Log in JSON so fields are searchable.

42. Blue-green vs canary?

Blue-green switches all traffic from the old environment to a full new one, with instant switch-back. Canary sends a small share of traffic to the new version first and widens it if metrics stay healthy.

Senior

43. Design a pipeline from commit to production.

On pull request: lint, unit tests, SAST, IaC scan, build. On merge: build one image tagged with the SHA, scan it, sign it, push it, deploy to staging, run smoke and integration tests, then promote the same image to production with an approval or automated canary analysis.

44. Why build once and promote?

Rebuilding per environment can produce a different artifact from what was tested. Promoting one immutable image guarantees that production runs exactly what staging validated.

45. GitOps or push-based deployment?

GitOps (Argo CD, Flux) pulls desired state from Git and corrects drift; clusters need no inbound credentials from CI. Push-based pipelines are simpler to start. For many clusters, GitOps usually scales better.

46. How do you manage configuration for many environments?

Keep one base with per-environment overlays (Kustomize) or values files (Helm), store secrets in a secret manager, and keep environment differences small and visible in Git.

47. How do you measure DevOps performance?

The DORA metrics: deployment frequency, change lead time, change fail rate and failed deployment recovery time, tracked as trends, not targets for individuals.

48. How do you make database changes safe in continuous delivery?

Use versioned migrations (Flyway, Liquibase or framework tools), make them backward compatible with expand-and-contract, and run them as a separate pipeline step with a tested rollback plan.

49. How do you handle a team that wants direct production access?

Give read-only observability by default and time-bound, logged elevated access when needed. Make the pipeline the normal way to change production.

50. How would you reduce cloud cost without hurting reliability?

Right-size from utilisation data, autoscale, use spot or preemptible capacity for stateless and batch work, delete unused resources, and set budgets with alerts per team.

Real-time troubleshooting

51. A pod is in CrashLoopBackOff. Walk through it.

kubectl describe pod for events and exit codes, kubectl logs POD --previous for the last crash. Exit code 137 suggests OOMKilled; config errors usually show in the logs. Check recent changes to the image, ConfigMaps and Secrets.

52. ImagePullBackOff after a release.

Check the image name and tag, whether it was pushed, and registry credentials (imagePullSecrets or node IAM). kubectl describe pod shows the exact pull error.

53. The Jenkins build fails with "No space left on device".

Clean old workspaces and Docker images on the agent (docker system prune with care), add build discarders to keep fewer builds, and move builds to ephemeral agents.

54. Terraform apply fails with "Error acquiring the state lock".

Another run holds the lock, or a crashed run left it. Confirm nothing is running, then use terraform force-unlock LOCK_ID. Find out why the earlier run died.

55. A Service returns connection refused, but pods are Running.

Check kubectl get endpoints SERVICE. Empty endpoints mean the selector does not match pod labels or pods are not Ready. Also confirm targetPort matches the container port.

56. Deploy succeeded but users see the old version.

Possible causes: a CDN or browser cache, the image tag latest not pulled again, or traffic still going to old pods. Use immutable tags and check which image the pods run with kubectl get pods -o jsonpath.

57. A Git merge conflict blocks a release.

Run git status, open the conflicted files, choose the right content, remove the markers, git add and commit. Talk to the other author if the intent is unclear, and run tests before pushing.

58. Latency doubled after a deploy, with no errors.

Compare the new version's p95 and p99 with the old one, check resource throttling (CPU limits), new database queries and external calls. Roll back first if users are affected.

59. A secret was printed in pipeline logs.

Revoke and rotate the secret immediately, delete or restrict the log, and fix the script that printed it. Enable masking and avoid set -x in steps that handle secrets.

60. Nodes in the cluster go NotReady one by one.

Check kubectl describe node conditions (MemoryPressure, DiskPressure, PIDPressure), kubelet logs on the node, and recent changes to node images or the CNI. Cordon and drain affected nodes while you investigate.

How to practise

Build one repository that goes from code to a running app on a local kind or minikube cluster with CI, an image registry, Terraform for a cloud bucket, and Prometheus alerts. Break it on purpose and fix it while explaining aloud. More practice: 110+ real-time DevOps questions and 100+ Jenkins questions. These labs form our DevOps course, with containers covered in depth in the Docker course, in Kharadi, Pune or live online.

FAQ

What are practical DevOps interview questions?

Questions that ask you to write a command, file or fix, such as a Dockerfile, a pipeline, a Kubernetes rollback or a Terraform change, rather than define a term.

How do I prepare for a hands-on DevOps round?

Build an end-to-end project, break it on purpose, and practise fixing it while explaining each step out loud.

What is the difference between git reset and git revert?

reset moves the branch pointer and rewrites history, so use it only on unpushed work. revert adds a new commit that undoes an earlier one and is safe on shared branches.

How do I debug CrashLoopBackOff?

Use kubectl describe pod for events and exit codes, and kubectl logs --previous to see why the last container run failed.

Which tools should a DevOps fresher know?

Linux, Git, one CI tool, Docker, Kubernetes basics, Terraform or Ansible, and one cloud provider.

Why build a container image only once?

So the exact artifact tested in staging is the one released to production.

How is this page different from the 20 most common DevOps questions?

The 20 questions page covers concepts briefly. This page is hands-on, with commands and files for each answer.

References

What's Your Reaction?

Like Like 1
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.