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 1–8 of 8 questions

Learn Docker →
1.How do you make images smaller and builds faster?Mid

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.

2.A container exits immediately after starting. How do you debug it?Mid

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.

3.How do containers on the same host talk to each other?Mid

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

4.What is a multi-stage build?Mid

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.

5.Why does the order of lines in a Dockerfile matter?Mid

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.

6.What is the difference between ADD and COPY?Mid

COPY just copies files. ADD can also download URLs and unpack local tar files, which can surprise you. Use COPY unless you need what ADD does.

7.What is Docker Compose used for?Mid

It runs a multi-container app from one compose.yaml: services, networks, volumes and environment. It is great for local development and tests, for example an app plus Postgres plus Redis with docker compose up.

8.Why should a container not run as root, and how do you change it?Mid

If an attacker breaks out of the app, root in the container makes escaping to the host easier. Create a user and add USER app in the Dockerfile, and in Kubernetes set runAsNonRoot: true.