Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
beatjost opened this issue Jul 17, 2018 · 2 comments
Closed

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

beatjost opened this issue Jul 17, 2018 · 2 comments

Comments

@beatjost
Copy link

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 {
      ...
    }
  }
}
@coollog
Copy link
Contributor

coollog commented Jul 17, 2018

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

@coollog coollog closed this as completed Jul 20, 2018
@beatjost
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants