Skip to content

Using unprivileged users #277

Closed
Closed

Description

@jaxxstorm

I'm trying to modify a docker image using the distroless base image. I added a USER directive to run as the binary, and as expected the run CMD failed due to the user not existing.

According to #235 it should be easy to override, but adding the user isn't actually possible because you can't RUN anything because of the lack of a shell.

How should one add another user here?

Activity

  1. chanseokoh commented on Jan 23, 2019

    @chanseokoh
    Member

    On Linux, you would normally use useradd and groupadd (e.g., like this), but of course, distroless doesn't have them, not to mention a shell.

    I believe all you need is to have the right entry in /etc/passwd (and /etc/group if applicable), so I guess you can supply a custom passwd file.

  2. jaxxstorm commented on Jan 23, 2019

    @jaxxstorm
    Author

    Yeah makes sense, thanks

  3. chanseokoh commented on Jan 24, 2019

    @chanseokoh
    Member

    Oh, I forgot to say this. If it is fine to use a uid (i.e., number) and you don't have to use a name (like myname), you don't necessarily have to add a user, for example, if all you want is to run your application inside the container as a non-root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions