Interview Q&A / Docker & Kubernetes

INTERVIEW Q&A · 67 QUESTIONS

Docker & Kubernetes interview questions

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

  1. Does depends_on in Docker Compose wait until the database is ready?

    By default no. depends_on only controls start order, not readiness. To wait for a healthy service, add a healthcheck and use depends_on with condition: service_healthy.

    IntermediateQuick answer1 min read
  2. How do you pass environment variables and secrets into services in Docker Compose?

    Use environment: for inline values, env_file: to load a file, and ${VAR} substitution from the shell or a .env file. Keep real secrets out of Git and prefer Compose secrets or an external secret store.

    IntermediateQuick answer1 min read
  3. What is docker-compose.override.yml and how is it used?

    Compose automatically merges docker-compose.override.yml on top of docker-compose.yml. Teams keep shared settings in the base file and development extras like bind mounts or debug ports in the override.

    IntermediateQuick answer1 min read
  4. What is the difference between docker compose up and docker compose run?

    up creates and starts all services (or those named) as defined, with ports and dependencies. run starts a one-off container for a single service with a command you give, then exits, and does not publish ports by default.

    IntermediateQuick answer1 min read