Skip to content

How can I create an image not running with root user? #631

Closed

Description

@beatjost

Description of the issue:
Default configuration gives me the following warning:

Image docker.io/company/app runs as the root user which might not be permitted by your cluster administrator.

Expected behavior:
Possibility to set a user or automatically use a specific user.

Steps to reproduce:

  • just run gradlew jib
  • pull image from registry (e.g. on openshift)
    -> warning that images runs on root user...

Environment:

jib-gradle-plugin Configuration:

jib {
  to {
    image = 'company/app:'+version
    auth {
      ...
    }
  }
}

Activity

  1. coollog commented on Jul 17, 2018

    @coollog
    Contributor

    Hi @beatjost , do you happen to be running the image with docker? If so, you can run the image with a specific user. I'd recommend 1000 as a default:

    docker run --user 1000 <image>
    

    If you are running on Kubernetes, I would recommend always running pods with a security context:

    Example from that page:

    apiVersion: v1
    kind: Pod
    metadata:
      name: security-context-demo-2
    spec:
      securityContext:
        runAsUser: 1000
      containers:
      - name: sec-ctx-demo-2
        image: gcr.io/google-samples/node-hello:1.0
        securityContext:
          runAsUser: 2000
          allowPrivilegeEscalation: false
  2. beatjost commented on Jul 23, 2018

    @beatjost
    Author

    Thank you for your reply - will try with 'security context'...

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