Sphere
Log in Join
☆ 10

docker containers running as root, how strict to be

our Dockerfiles mostly don't set USER, so containers run as root inside the namespace. security team is pushing to add non-root users everywhere. is this meaningful or mostly checkbox compliance? we'd have to fix file permissions in about 20 images.

⚑ Report

4 replies

☆ 0
B blame ·2026-11-01#1

it's meaningful if a container escape or app RCE happens — root in the container can often do more damage (mount tricks, reading host-mounted files). adding USER 10001 and chown'ing the app dir is standard hardening. not a silver bullet but worth it.

⚑ Report
☆ 0
D darkmode ·2026-11-05#2

fair. some images need to bind port 80 and write to mounted volumes owned by host uid 1000. how do people handle that without chmod 777 everywhere?

⚑ Report
☆ 0
D duct ·2026-11-06#3

for ports, use 8080 inside and map 80:8080 at runtime. for volumes, set the container user to match the host uid (e.g. USER 1000:1000) or fix ownership on the host dir at deploy time. avoid 777, just align uids.

⚑ Report
☆ 0
V vector ·2026-11-08#4

added non-root users to all 20 images, used high ports internally and matched uid 1000 for volume writes. took a couple days of fiddling but nothing broke. security team happy, and it's genuinely better.

⚑ Report
Log in to reply.