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 check a container's IP address, environment variables and resource usage?

    docker inspect shows full JSON details such as IP, env vars, mounts and state, and -f with a Go template pulls out one field. docker stats shows live CPU, memory and network usage.

    BeginnerQuick answer1 min read
  2. How do you find out why a Docker container exited immediately?

    Run docker ps -a to see its status and exit code, then docker logs for the output. A container lives only as long as its main process, so a quick exit means the process finished or crashed.

    BeginnerQuick answer1 min read
  3. What is the difference between docker exec and docker attach?

    docker exec starts a new process inside a running container, such as a shell. docker attach connects your terminal to the container's existing main process, so exiting it can stop the container.

    BeginnerQuick answer1 min read
  4. A Kubernetes Service is not routing traffic to your Pods. How do you debug it?

    Check kubectl get endpoints for the Service. If it is empty, the Service selector does not match the Pod labels, or the Pods are not ready. Also verify targetPort matches the container port.

    IntermediateQuick answer1 min read
  5. How can you see what is making up the size of a Docker image?

    docker history lists every layer with its command and size. For file-level detail, the open-source tool dive shows what each layer adds or wastes, which helps you spot big leftovers.

    IntermediateQuick answer1 min read
  6. You created an Ingress but nothing works. What could be missing?

    Usually no Ingress controller is installed, so no one reads the rules. Also check ingressClassName, that the backend Service and port exist, DNS pointing to the controller's address, and that Pods are ready.

    IntermediateQuick answer1 min read