Skip to content

Consider having the default distroless tags use non-root user by default #374

Closed

Description

@dprotaso

Continuing the discussion from #368

Activity

  1. Renz2018 commented on Jun 24, 2019

    @Renz2018

    How about add java:8-nonroot and java:11-nonroot???

  2. evanj commented on Sep 16, 2019

    @evanj
    Contributor

    The switch to debian10 would actually be an opportunity to introduce this change, since it is going to break compatibility anyway?

  3. yegle commented on Nov 8, 2019

    @yegle
  4. chanseokoh commented on Nov 8, 2019

    @chanseokoh
  5. yegle commented on Nov 8, 2019

    @yegle
  6. chanseokoh commented on Nov 8, 2019

    @chanseokoh
  7. yegle commented on Nov 8, 2019

    @yegle
  8. chanseokoh commented on Nov 8, 2019

    @chanseokoh
  9. yegle commented on Nov 9, 2019

    @yegle
  10. chanseokoh commented on Nov 9, 2019

    @chanseokoh
    Member

    I'm totally fine with :latest being :nonroot.

    Cool! Looks like I can take this as a definite answer that you actually do not have any objection on this issue. I initially thought you were opposing, as you had asked for "reconsideration" on this matter. Switching the default won't affect your situation, after all.

    It would be more useful if you also have an image :nonroot-with-setcap, to make some people's life easier.

    Definitely, this is something conceivable, but to be completely honest, I think this isn't really the right direction for Distroless (or any other similar base images) to take and maintain it, for a number of reasons. But primarily, this setcap issue (moby/moby#35699) should really be fixed at the root. Actually, looking at the bug, they seem to agree that this should be resolved at the Docker level in today's environment, and indeed, they are actively working on this (draft PR here) to resolve the issue.

    I need to copy setcap and its shared objects from a burster image?

    That is one way to do it. Another option I can think of is rebasing (https://github.com/google/go-containerregistry/blob/master/cmd/crane/rebase.md, https://github.com/google/image-rebase, or https://github.com/codahale/docker-rebase), and this may be an easier approach to some people. Another workaround I found is to import a tarball, and perhaps this may also prove easier. I believe many people have hit this issue, so there may be more workarounds, I don't know.

  11. JonathanParra commented on Dec 19, 2023

    @JonathanParra

    Inquiry: Is it possible to, in an image or Dockerfile using Distroless, besides the ':nonroot' tag, also define a 'USER nonroot'? This is because, when scanning images with Trivy, it does not detect root, and as a consequence, it generates a HIGH vulnerability.

  12. loosebazooka commented on Dec 20, 2023

    @loosebazooka
    Member

    I'm not sure I understand the problem? Can you elaborate? The users are in all images. The tag is just setting the default user.

  13. rudfoss-rr commented on Nov 14, 2025

    @rudfoss-rr

    Sorry for reopening an old thread, but I've run into what I believe is the same issue as @JonathanParra. Our Trivy scan reports:

    Dockerfile (dockerfile)
    
    Tests: 20 (SUCCESSES: 19, FAILURES: 1)
    Failures: 1 (HIGH: 1, CRITICAL: 0)
    
    AVD-DS-0002 (HIGH): Specify at least 1 USER command in Dockerfile with non-root user as argument

    For this container:

    FROM gcr.io/distroless/nodejs24-debian12:nonroot
    
    WORKDIR /app
    COPY --from=build /app .
    
    CMD ["app.js"]

    It seems Trivy does not detect this as a non-root container. Or am I maybe missing something?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions