Skip to content
$ lynuxpro

INTERVIEW PREP

Interview questions

570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.

Showing 16–30 of 54 questions

16.How do you read a file safely?BeginnerPython for DevOps

Use a with block: with open(path) as f. It closes the file even when an error happens. pathlib makes paths work on every system.

17.What does exit code 0 mean?BeginnerPython for DevOps

Success. Any other number means failure. CI systems and shells read this number, so scripts should exit non-zero when they fail.

18.What is the difference between a function and a module?BeginnerPython for DevOps

A function is a named block of steps you can call again and again. A module is a .py file that holds functions and other code, so you can import and share them.

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

An image is a read-only template made of layers. A container is a running instance of an image with its own writable layer, process namespace and network.

20.What is the difference between CMD and ENTRYPOINT?BeginnerDocker

ENTRYPOINT sets the executable; CMD supplies default arguments (or the default command if there is no ENTRYPOINT). docker run image args replaces CMD but not ENTRYPOINT.

21.What is a Dockerfile, and what do FROM, RUN, COPY and EXPOSE do?BeginnerDocker

A Dockerfile is the recipe for an image. FROM picks the base image, RUN runs a command at build time and saves the result as a layer, COPY adds files from the build context, and EXPOSE documents the port the app listens on (it doesn't publish it).

22.What is the difference between docker stop and docker kill?BeginnerDocker

docker stop sends SIGTERM, waits (10 seconds by default) for a clean shutdown, then sends SIGKILL. docker kill sends SIGKILL right away, so the app can't clean up.

23.How do you keep data when a container is removed?BeginnerDocker

Store it in a volume (-v data:/var/lib/postgresql/data) or a bind mount to a host folder. The container's own writable layer is deleted with the container.

24.What does -p 8080:80 mean?BeginnerDocker

Publish port 80 inside the container on port 8080 of the host, so http://localhost:8080 reaches the app.

25.What is the difference between a Deployment, a ReplicaSet and a Pod?BeginnerKubernetes

A Pod runs one or more containers. A ReplicaSet keeps a number of identical Pods running. A Deployment manages ReplicaSets to give rolling updates and rollbacks; you normally only create Deployments.

26.How does a Service find its Pods?BeginnerKubernetes

Through its label selector. The endpoints controller lists ready Pods whose labels match, and kube-proxy (or the CNI) routes the Service's virtual IP to them.

27.What are the main parts of a Kubernetes cluster?BeginnerKubernetes

The control plane runs the API server, etcd (the database), the scheduler and the controller manager. Each worker node runs kubelet, a container runtime and kube-proxy (or a CNI that replaces it). You talk to the API server with kubectl.

28.What is a namespace used for?BeginnerKubernetes

It groups resources inside one cluster, for example per team or environment, and is the unit for RBAC, resource quotas and network policies. It is not a hard security boundary on its own.

29.What is the difference between a ConfigMap and a Secret?BeginnerKubernetes

Both hold configuration for Pods. Secrets are meant for sensitive data and are base64-encoded, not encrypted by default; turn on encryption at rest and limit access with RBAC, or use an external secret manager.

30.What are the Service types?BeginnerKubernetes

ClusterIP (internal only, the default), NodePort (a port on every node), LoadBalancer (a cloud load balancer) and ExternalName (a DNS alias). Ingress or Gateway API sit on top to route HTTP by host and path.