brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: one docker inspect line shows which containers run privileged, a quick security audit

Security
~/tips/tip-security-find-privileged-containers

docker ps -q | xargs docker inspect -f '{{.Name}} privileged={{.HostConfig.Privileged}}'

Lists every running container together with its privileged flag.

A container started with --privileged gets every capability and access to all host devices. It is the first thing I’d look for when taking over a box someone else set up.

This prints one line per running container:

docker ps -q | xargs docker inspect -f '{{.Name}} privileged={{.HostConfig.Privileged}}'

Every container marked privileged=true deserves a reason. Some tools really need it, like a few hardware monitoring or VPN images, but often it was copied from a forum post to make an error go away.

The same inspect output shows other risky settings. I’d add these to the template:

docker ps -q | xargs docker inspect -f '{{.Name}} caps={{.HostConfig.CapAdd}} pid={{.HostConfig.PidMode}} net={{.HostConfig.NetworkMode}}'

Added capabilities such as SYS_ADMIN, pid=host and net=host each give a container a bigger piece of the host. Fixing it means removing the flag and adding back only the one capability or device the container needs, with --cap-add or --device.

This only covers running containers. Stopped ones that start again at boot are just as relevant, so add -a to docker ps for the full picture. And bind mounts of / or of the Docker socket give root access too, without the privileged flag.

Further reading: docker container inspect reference, Docker run reference: runtime privilege

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link