Interview Prep/Python for DevOps/Kubernetes, Docker, SSH & fleet automation

You discover a Python tool mounts `/var/run/docker.sock` into its container to list containers. What is the risk and alternative?

AdvancedScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Docker socket access equals root on the host.

What I'd do →

  1. Explain: anyone who compromises the tool can start a privileged container mounting / and own the host.
  2. Alternatives: use the Kubernetes API (on k8s), cAdvisor or node metrics for read-only data, or a socket proxy (docker-socket-proxy) allowing only GET /containers.
  3. If unavoidable, run the tool isolated, read-only root, minimal network, and audited.

Why → Least privilege applies to sockets too.

Interview tip → Say "docker.sock is root" in the first sentence.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation