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 126 questions
16.What is a here document, and when would you use one?MidBash Scripting
A here document feeds several lines to a command: cat <<'EOF' > config.yml ... EOF. Quoting 'EOF' stops variable expansion, which is handy for writing config files or sending a block of commands over SSH.
17.Why is shell=True dangerous in subprocess?MidPython for DevOps
The text is parsed by a shell, so special characters from outside input can run extra commands. Pass the command as a list of arguments instead.
18.How do you call a REST API safely from Python?MidPython for DevOps
Use requests with a timeout, call raise_for_status(), keep tokens in environment variables, handle paging, and retry on 429 and 5xx.
19.What is yaml.safe_load and why prefer it?MidPython for DevOps
It parses YAML into plain data only. The unsafe loader can create arbitrary Python objects, so a crafted file could run code.
20.What does idempotent mean for an automation script?MidPython for DevOps
Running it again gives the same end result and causes no harm. Check what exists first, then create, update or skip.
21.Why use logging instead of print?MidPython for DevOps
Logging gives timestamps and levels, can write to files, and can be turned up or down without changing code.
22.What is exponential backoff?MidPython for DevOps
Waiting longer after each failed try, such as 1s, 2s, 4s. It gives a busy service time to recover. Always cap the number of tries.
23.How do you test code that calls AWS?MidPython for DevOps
Mock the client in unit tests or use moto to fake AWS. Keep real-cloud tests few, slow and separate.
24.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.
25.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.
26.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.
27.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.
28.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.
29.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.
30.What is the difference between ADD and COPY?MidDocker
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.