Skip to content

docker image: switch to a new non-root user when started as root#241

Open
arichardson wants to merge 5 commits intomasterfrom
docker-entrypoint
Open

docker image: switch to a new non-root user when started as root#241
arichardson wants to merge 5 commits intomasterfrom
docker-entrypoint

Conversation

@arichardson
Copy link
Member

Instead of manually adding a matching user with the docker-adduser
cheribuild target, this adds an ENTRYPOINT script to the docker image
that automatically creates an unprivileged user. The UID/GID/name can
be passed using environment variables (-e flag to docker run).

@arichardson arichardson requested review from gvnn3 and jrtc27 September 7, 2021 14:19
@arichardson
Copy link
Member Author

I believe this should now be correct.

@jrtc27
Copy link
Member

jrtc27 commented Sep 10, 2021

My only concern with merging this is that the initial release tarball (which we know some people are using) failed to check out a tag for cheribuild, so it tracks master and prompts people to update, meaning we can't actually make the cheribuild side of the necessary changes to support this because that will break with people's existing docker images. I don't know how we deal with that though because it'll need breaking at some point, and other changes to cheribuild may stop things working with the release's snapshot of repos before then...

@arichardson
Copy link
Member Author

Yes that is unfortunate. However, these dockerfile changes should be backwards compatible since they do nothing when --uid is passed to docker.

I'll look into a workaround for the release when I actually make the docker commandline change.

Instead of manually adding a matching user with the docker-adduser
cheribuild target, this adds an ENTRYPOINT script to the docker image
that automatically creates an unprivileged user. The UID/GID/name can
be passed using environment variables (-e flag to `docker run`).
Unlike adduser, the low-level useradd program does not have any prompts
so works better in a non-interactive context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants