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 →
- Explain: anyone who compromises the tool can start a privileged container mounting
/and own the host. - Alternatives: use the Kubernetes API (on k8s), cAdvisor or node metrics for read-only data, or a socket proxy (
docker-socket-proxy) allowing onlyGET /containers. - 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.
More on Kubernetes, Docker, SSH & fleet automation
You need a report of every pod in the cluster with no CPU or memory limits. How do you write it?BeginnerYou are asked to write a small operator-like script that adds a label to every new namespace. How do you approach it?AdvancedYou need to restart all Deployments in a namespace that reference a rotated Secret. How?AdvancedYour CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.IntermediateYou need to run `df -h` on 300 Linux hosts and list any above 85%. Python or Ansible?BeginnerA Python script SSHes to hosts with `AutoAddPolicy`. Security says that is unacceptable. What do you change?Intermediate