Skip to content

[docker] Run as non root #5311

@janhoy

Description

@janhoy

Is your feature request related to a problem? Please describe.

Many users enforce policies that docker containers should not run as root user. There should be no reason to run as root by default.

Describe the solution you'd like

Create a user and set USER in Dockerfile.

Additional context

A sample warning from a k8s deploy is like this:

policy require-run-as-nonroot/run-as-non-root fail: validation error: Running as root is not allowed. Either the field spec.securityContext.runAsNonRoot must be set to true, or the fields spec.containers[].securityContext.runAsNonRoot, spec.initContainers[].securityContext.runAsNonRoot, and spec.ephemeralContainers[*].securityContext.runAsNonRoot must be set to true. rule run-as-non-root[0] failed at path /spec/securityContext/runAsNonRoot/ rule run-as-non-root[1] failed at path /spec/containers/0/securityContext/runAsNonRoot/

Metadata

Metadata

Assignees

No one assigned

    Labels

    security fixSecurity fix generated by WhiteSource

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions