Interview Q&A / Docker & Kubernetes

INTERVIEW Q&A · 67 QUESTIONS

Docker & Kubernetes interview questions

Images, containers, Dockerfiles, pods and deployments, from first principles.

  1. How do you mount a volume or folder as read-only in a container?

    Add :ro to the -v option, or readonly in --mount. The container can then read the files but any write attempt fails. This protects config files and source mounts from accidental changes.

    BeginnerQuick answer1 min read
  2. Why should you never put passwords or API keys in a Dockerfile or image?

    Anything baked into a layer, through ENV, ARG, COPY or RUN, can be read by anyone who can pull the image, using docker history or by unpacking layers. Inject secrets at runtime instead.

    BeginnerQuick answer1 min read
  3. Why should you pin the base image version in a Dockerfile?

    FROM python without a version or with latest can change between builds, so a rebuild may break or introduce new vulnerabilities. Pinning a specific tag or digest gives repeatable builds you update on purpose.

    BeginnerQuick answer1 min read