Interview Q&A / Docker & Kubernetes

INTERVIEW Q&A · 67 QUESTIONS

Docker & Kubernetes interview questions

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

  1. Why is data in a container temporary, and what are Docker volumes and bind mounts?

    Files a container writes go into its own writable layer, which is deleted when the container is removed. To keep data, you mount storage from outside the container. A volume is storage managed by Docker; a bind mount maps a specific folder from the host into the container.

    BeginnerIn-depth3 min read
  2. Does data in a Docker volume survive docker rm?

    Yes. Removing a container does not remove its named volume. Anonymous volumes are also kept unless you use docker rm -v. Data is deleted only when you run docker volume rm or prune.

    BeginnerQuick answer1 min read
  3. 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
  4. What is the difference between a named volume and a bind mount?

    A named volume is storage created and managed by Docker, stored in its own area and portable between containers. A bind mount maps an exact host folder into the container, which suits live code editing but depends on the host layout.

    BeginnerQuick answer1 min read
  5. What is the difference between docker compose stop, down and down -v?

    stop halts containers but keeps them. down stops and removes containers and networks. down -v also deletes the named volumes, which destroys stored data.

    BeginnerQuick answer1 min read