How can a dangling volume leak sensitive data, even though a normal host user cannot read it directly?
Deleting a container does not delete its volume; the orphaned (dangling) volume still holds its data, and any new container that mounts it by name can read the files — bypassing the host file permissions that block a normal user.
Volumes deliberately outlive containers: removing a container (even one run with --rm) leaves its named volume behind as a dangling volume (docker volume ls -f dangling=true). If that volume held secrets — credentials, keys, tokens — the data is still there under /var/lib/docker/volumes/<name>/_data.
On the host, that data is protected by file permissions: an unprivileged user cannot cat the file directly (the lab writes it chmod 600, owned by root). So it looks safe. But the protection is bypassed from a container:
docker run -it --rm --mount type=volume,src=credentials,dst=/secrets alpine sh
cat /secrets/secretfile # readable — the container process is root
Because container processes run as root and the volume is simply mounted in, the file is readable. The attack scenario: a malicious image scans for dangling volumes, mounts them, and exfiltrates whatever it finds.
Defences: prune volumes you no longer need (docker volume prune), don't leave secrets in volumes, and don't run untrusted images that could mount them (again, non-root containers and user namespaces reduce the damage).
Go deeper:
Docker Docs: Volumes — volume lifecycle, inspection and pruning dangling volumes.