-
Notifications
You must be signed in to change notification settings - Fork 18
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
Could not create parent directory for lock file when a non-root user #10
Comments
thanx for your problem report. I do understand the problem. I guess the best solution is to modify the docker file to fit your needs: https://github.com/docToolchain/docker-image/blob/master/alpine/Dockerfile I am currently trying to re-write docToolchain in a way that it is more usable - this will include a new docker file. But at the moment, the docker file is more experimental. It seems to work for some use cases but anfortunately not for yours. I guess the solution needed is to switch the user in the docker file in order to install sdkman and gradle as another user and run the docker file with this user. |
Hi @rdmueller, here is our temporary solution. In our case we know that the container will started using UID 300 GID 300. So we create such a user (jenkinsuser with 300:300) and its home directory in the image itself. Gradle in the Dockerfile is initially invoked within
|
great to see that you've found a solution which works for you. But I also have the feeling that this is a solution from which others could benefit. |
today I tried to get it to work and here is what I came up with:
you can now specify a user as A new image will be soon available as |
ok, the newest build will allow you to run the container with any user. |
which newest build ? iam still getting the same error: is there a chance to get a docker version of doctoolchain running as non root user ? |
this is the currently used dockerfile to create the And this is how it is used by the wrapper: does this help? |
How to run the image using a non-root user offline?
The previously downloaded already locally available gradle distribution (downloaded at the moment of building the https://github.com/docToolchain/docker-image/blob/master/alpine/Dockerfile) should be used.
Problem
I integrated this docker-image in my Jenkins-CI pipeline like this.
Which is equivalent to
or
from your documentation. Note the added option
--user jenkinbuilduser
and--user 501
.But this leads to exceptions like
My investigations showed that
/root/.gradle
(which holds the downloaded gradle distribution created by https://github.com/docToolchain/docker-image/blob/master/alpine/Dockerfile#L41) is not accessible by a non-root user likejenkinbuilduser
. gradlew interprets it that no distribution is locally available and starts the download of the gradle distribution into/docToolchain/?/.gradle
. This directory is read-only, which leads to the exception.First workaround (non-working)
My first workaround was to run the image as user root.
Which is equivalent to
(Note the option
--user root
)This way there is no exception, the generation works, but the generated file are owned by user root on the host file-system. This is not acceptable, because these files cannot be removed anymore (at least not by a next build steps within the build job. It can only be deleted manually by a fellow administrator with root-user rights)
Second workaround (partially working)
Set a non-root user and a rw-directory for the gradle distribution.
gradlew will download a distribution to
/project/.gradlecustom
, the generation succeeds and the generated files are owned by a non-root user.The problem: A buildjob should not have access to the internet.
The remaining problem
The issue is still remaining: How to run the image using a non-root user offline. The previously downloaded already locally available gradle distribution should be used.
The text was updated successfully, but these errors were encountered: