Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the docker exec --privileged flag do?

I've come across the --privileged flag for docker exec, but the manual does not provide much of an explanation:

--privileged      Give extended privileges to the command

That's all. No more explanation or example.

Searching the web for more info, I only found descriptions of containers running in privileged mode, but it appears to me that this doesn't have anything to do with the privileged mode of docker exec. I assume that these privileges apply to the executed command, and I imagine that it means that it is run under a privileged user (root). But then, I wonder what the difference would be compared to docker exec -u 0?

like image 300
not2savvy Avatar asked Feb 08 '26 04:02

not2savvy


1 Answers

By default, container runtimes go to great lengths to shield a container from the host system. Running in --privileged mode disables/bypasses most of these checks. This basically means that if you are root in a container you have the privileges of root on the host system. It is only meant for special cases such as running Docker in Docker (for example, in pipeline for sharing the docker socket from the host) and should be avoided.

like image 166
czende Avatar answered Feb 12 '26 04:02

czende



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!