-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Cannot run image running with container generated by jib as non-root in k8s #727
Comments
Hi @JamesWojewoda, I believe this is related to #523. I think we have a fix planned for not this upcoming release, but the release after (0.9.9). |
@JamesWojewoda your issue sounds similar to this question: |
@TadCordle Yeah, I think you're on the money. That's good to know! Looking forward to it cause using jib so far has been great. @briandealwis I'll try tinkering with the volume. Currently I can't seem to mount anywhere but the /app/resources folder. |
Another option may be to add configuration for the user (uid, groupid, names..) and write the files with the configured user and set the container config |
Hi @JamesWojewoda I filed #772 with a potential fix. Would you mind trying that fix to see if it works for your error?
|
@coollog Installed and tested, I see that the subdirs of /app are now readable/executable by other users. Still getting the error however, is this possibly due to /app still having only root access? |
Hi @JamesWojewoda , I just pushed a commit to add |
@coollog After install, I'm seeing the other root dirs as readable and executable, however /app is still only root accessible
|
@JamesWojewoda Oh, maybe try running your Maven build with |
@coollog Yup that was it, thanks for that. I thought I deleted the locally held jib and upped the version, possibly something wonky happened with my iterm and using multiple windows. |
@JamesWojewoda Okay great! Glad that worked - we will have that fix in for version |
@coollog The app dir has been updated, unfortunately I'm still seeing the error cant find main class - but I did notice the com subdir getting created under /app/classes is still only available to root. |
@coollog Unrelated, but I'm curious why |
@chanseokoh Yea, this is definitely quite puzzling. |
@coollog Heres the permissions on my jenkins maven container that uses jib to build the image: /target/classes /target/classes/com /target/classes/com/(classes in the proj) |
Hi @JamesWojewoda , can you try again with the latest change? I pushed a fix to set permissions for all directories.
|
@coollog When using an image generated via that branch, I'm getting the following error: rpc error: code = Unknown desc = failed to register layer: ApplyLayer duplicates of file paths not supported stdout: {"layerSize":349759} The image was put into an ECS repo, and when trying to pull and run the image locally I get: |
Hi @JamesWojewoda , I made some changes to guarantee no duplicates in the tarball entries. Can you try again and see if it works now?
|
@coollog Now working, however the dirs have gone back to being root only. container image: /app /app/classes /app/classes/com target folder: |
@JamesWojewoda Hmm, this is a puzzler. Could you try building to a Docker daemon with ( |
@coollog It failed trying to build it with the docker daemon as well.
|
@JamesWojewoda Hmm, could you try building the tarball and doing
|
@coollog Same issue, I'm afraid. The tar builds ok however. Error processing tar file(duplicates of file paths not supported): |
I'm also having the same issue, if needs some help to debug just get in touch with me too. |
Hmm, this looks like the same issue happening at bazelbuild/rules_docker#246 |
@JamesWojewoda the original fix had a bug that caused the After some more discussions, we are planning to add a configuration to
This will make sure all the files are created with 10000 as the uid. |
@JamesWojewoda Can you try again with the fix at #891? It might just work for your case and wouldn't need the
|
@coollog This works great. Thanks for your help! |
@coollog I had the same problem as @JamesWojewoda and can confirm that after the recent changes, the image was successfully loaded and the permissions was right as you can see: $ ls -lah app Much appreciated those changes 👍 |
@JamesWojewoda Awesome! We'll get that merged in for |
@GuustavoPaiva Great! |
@JamesWojewoda @GuustavoPaiva We have released version |
mvn compile jib:buildTar |
@yangguang001 please open a new issue and include:
|
Description of the issue: I cannot run the image generated via jib-maven-plugin as nonroot. When attempting to set the securitycontext runasuser as a custom one, it errors as the app cannot find the main class. Only root seems to work, but this is a security issue and I'd rather run the container as a unpriviledged user.
Expected behavior: set the security context in the k8s deployment as uid 10000 (just an example), and the app thats generated has /app folders owned or at least executable by this uid.
Steps to reproduce: create a k8s deployment, set securitycontext: runasUser: to custom uid. use a custom jdk image and use that USER uid in the from block of the maven-jib-plugin section in the pom.xml
Environment:
jdk image utilized by pom to generate the new image for the java app:
jib-maven-plugin
Configuration:Log output: Error: Could not find or load main class com.test.hello.HelloApplication
Additional Information: the folders that are generated in /app are owned by root. resources is available to all users, but the other 2 are root write and executable only.
k8s deployment container:
The text was updated successfully, but these errors were encountered: