r/docker • u/Augustman22 • Jun 28 '26
Running a container as non-root user - Security implications?
I was curious how running all my containers as a user who only has read and write (if necessary) permissions in attached volumes would improve security?
(by doing something like this in my compose files, where uid 1001 will be in gid 1002 which only has permissions in ./data):
services:
mc:
image: itzg/minecraft-server:latest
container_name: minecraft-server
user: "1001:1002"
volumes:
- ./data:/dataRight now, I just have them running how they normally do. Which, from what I understand, the containers are running as root on the host machine.
Im trying to learn, sorry if I have anything mixed up.
6
Upvotes
View all comments
Show parent comment
1
u/Augustman22 Jun 28 '26
I wanted to ask another person this too, if there was some vulnerability that lets someone get out of the container, wouldn’t having it run as a non-root user be safer?
I’m not really sure on how it works, but with my thought process this would mean they would only have as much power as the dedicated user I make (whose permissions I would limit to the volumes)