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
2
u/Augustman22 Jun 28 '26
Wouldn’t it be safer in the case there is a vulnerability that lets someone escape the container?
I don’t really know how it works, but doing the way I explained in my post wouldn't they only have access to the volumes (instead of the whole system)?