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