- Notifications
You must be signed in to change notification settings - Fork1.9k
Comments
Drop root privileges in Docker container#2825
Conversation
koalaman commentedOct 8, 2023
This change risks breaking CI and requires workarounds for anyone who's not checking world-readable files. Are there any Docker guidelines or conventions that recommend this approach? |
jtesta commentedOct 9, 2023
The Center for Internet Security (CIS) Benchmark for Docker states in section 4.1 that containers should be run as non-root whenever possible (seehttps://www.cisecurity.org/benchmark/docker). Furthermore, running as non-root by default would be applying the Principle of Least Privilege. As for filesystem permissions, default Ubuntu systems have a umask of 0002 (meaning files are already world-readable). So this would not be a problem. In the event that this is changed, though, users can add Because most users simply copy/paste from the documentation, we can very easily add the |
meadowbees commentedMay 8, 2025
Running as an unprivileged user makes sense for reducing security risks. Good call! I agree with this. |
jtesta commentedMay 23, 2025
Bump. |
50074dc toeac8effCompare
By default, Docker runs containers with root privileges (!). This isn't necessary for shellcheck. This PR causes the container to be run as an unprivileged user instead.
FYI, the highest possible UID and GID (65535) must be used in this patch since the final scratch image does not include /etc/passwd, /etc/group, nor the support code to resolve names to UIDs/GIDs.