Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Drop root privileges in Docker container#2825

Open
jtesta wants to merge 1 commit intokoalaman:masterfrom
jtesta:docker_drop_privs
Open

Drop root privileges in Docker container#2825
jtesta wants to merge 1 commit intokoalaman:masterfrom
jtesta:docker_drop_privs

Conversation

@jtesta
Copy link

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.

@koalaman
Copy link
Owner

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?

tremblaysimon and vivodi reacted with thumbs up emojitremblaysimon and vivodi reacted with heart emoji

@jtesta
Copy link
Author

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-u $(id -u):$(id -g) to theirdocker run command, which would run the container as the host user.

Because most users simply copy/paste from the documentation, we can very easily add the-u part tohttps://github.com/koalaman/shellcheck/blob/master/README.md?plain=1#L214. Adding-u to the CI config would also be easy.

cdesiles, meinzer1899, heitorPB, HeinrichAD, tacerus, lucavallerini, mengzhuo, rwaffen, donaldm314, pierresebastien, and 2 more reacted with thumbs up emoji

@meadowbees
Copy link

Running as an unprivileged user makes sense for reducing security risks. Good call! I agree with this.

wesley-dean, jtesta, and timo-reymann reacted with thumbs up emojivivodi reacted with thumbs down emojivivodi reacted with confused emoji

@jtesta
Copy link
Author

Bump.

@koalamankoalamanforce-pushed themaster branch 4 times, most recently from50074dc toeac8effCompareNovember 5, 2025 03:37
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@ZetaMaster777ZetaMaster777ZetaMaster777 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jtesta@koalaman@meadowbees@ZetaMaster777

[8]ページ先頭

©2009-2026 Movatter.jp