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 61–75 of 229 questions

61.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.

62.What does a --dry-run flag do, and why add it?MidPython for DevOps

It shows what the tool would change without changing anything. People can check the result first, so a mistake costs nothing.

63.How do you stop a script from hanging on a slow command or API?SeniorPython for DevOps

Set a timeout on every outside call: timeout= in requests and subprocess.run, and a limit on retries. Without one, a single stuck call can hang the whole job.

64.A user asks the API to start a 10-minute deploy. How do you design the endpoint?SeniorPython for DevOps

Check the input and the caller's permissions, put the job in a queue or background worker, and return 202 with a job id right away. Provide a status endpoint, log who started it, and make the job safe to run twice.

65.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.

66.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.

67.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).

68.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.

69.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.

70.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.

71.How do you make images smaller and builds faster?MidDocker

Use multi-stage builds, a small base (slim, distroless, alpine where appropriate), order instructions so rarely changing layers come first, use .dockerignore, and combine package install and cleanup in one RUN.

72.A container exits immediately after starting. How do you debug it?MidDocker

docker ps -a for the exit code, docker logs <id> for output, then docker run -it --entrypoint sh image to look inside. Common causes: the main process runs in the background, a missing env var, or wrong file permissions.

73.How do containers on the same host talk to each other?MidDocker

Put them on the same user-defined bridge network; Docker's embedded DNS resolves container names. The default bridge network has no name resolution.

74.What is a multi-stage build?MidDocker

A Dockerfile with several FROM stages: you build in a big image with compilers, then COPY --from=build only the result into a small runtime image. The final image is smaller and has fewer vulnerabilities.

75.Why does the order of lines in a Dockerfile matter?MidDocker

Each instruction is a cached layer, and a change invalidates every layer after it. Copy dependency files and install dependencies first, then copy the source code, so code changes don't reinstall everything.