-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Permission denied - /var/jenkins_home/copy_reference_file.log #177
Comments
Hi, Do you run your container on host which have SeLinux enable ? Try with '--privilleged' option, it may run. This may not be an durable fix, it's just for test. |
what jenkins image version? the latest? did you docker pull? |
I just pulled the latest this morning, and I had the same issue. My thoughts were that since the directory I wanted to volume to was empty that caused the issues. Ran without volume and it's starting. I'm going to pull the files from /var/jenkins_home to my local directory and see how that goes. I'll report back. docker run -p 8080:8080 -p 50000:50000 -v /opt/jenkins:/var/jenkins_home jenkins |
As described from @I12crash the problem only occurs when you mount an external volume. This is repeatable with the following...
The Dockerfile sets the user to "jenkins" when mounting the directory docker sets this under root.
So either don't switch to jenkins, which will solve this issue, or add sudoers to copy the files, let me know your thoughts are or whether you have any other solutions? |
I've hit this with a brand new install today. Looking for a workaround now. Be advised of moby/moby#7198 (comment) in considering the solution |
This is the same as #155 and documented in README
You must set the correct permissions in the host before you mount volumes An alternative is discussed in #158 |
Resolved albeit with torture involved.
Do NOT |
Added a warning when the jenkins home can't be written to, but this is a matter of using the correct volume/container permissions with Docker |
@carlossg the problem is triggered when using a host directory as a data volume, since chown is run only once at build-time. A fix may be to move the chown later, in the jenkins.sh script, so it get executed every time a container is started. |
No, that is not possible. The container is run as There is an alternative in #158 |
I've just come across this. My easy solution is to run as instructed. The container dies. I then change permissions on the folder it created to 777. Then start the container again. It will work. |
@mikeprice99's solution worked for me. |
@mikeprice99 |
Setting to 777 is just a temporary fix: once you've got it to work you can On 22 January 2016 at 23:40, Ryan Hartje notifications@github.com wrote:
|
#177 (comment) fixes the problem: If the directory already contains files: |
To save someone else burning 2-3 hours trying to debug the same issue I had... If you've mounted another disk to a path on the host after starting the Docker service Docker will mount the underlying directory, not the drive that is now mounted. You need to restart the Docker service before Docker will use the mounted drive (the comments about directory perms above still apply). |
Same issue today on 1.642.2. I actually don´t see why the permissions should be changed on the host. I have a bunch of docker images all working fine without tweaking of the volume permissions. I am running the container on a NAS thus I cannot teak too much on the users permissions. The volume is mounted RW. Why does Jenkins require more 'care' than other images (such as mongodb, nginx, mariadb, redis, gitlab, ....)? |
because those other images are running as root, doing the chown for you and then switching to a different user. That's what #158 would do |
As mentioned in #277, uid 1000 and gid 1000 are commonly occupied by users/groups in many candidate host operating systems. Because of the issue discussed here of needing to ensure files of the host system's mounted directory are set to the uid and gid of the |
For anybody still fighting this My docker file:
The entrypoint:
As in https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/entrypoint |
Ok, Got lost in issue graph..anyway this issue is the first that Google finds so maybe someone finds gosu solution useful. |
I know this is an old thread, but this is how I fixed this issue to have jenkins run as a specific user on the host (with correct permissions): FROM jenkins:latest
ARG HOST_UID
ARG HOST_GID
USER root
RUN echo $HOST_UID $HOST_GID $JAVA_OPTS
RUN groupmod -g ${HOST_GID} jenkins
RUN usermod -u ${HOST_UID} -g ${HOST_GID} jenkins
USER jenkins then I provide |
sudo chown -R 1000:1000 volume_dir |
Changing permission of $PWD/jenkins to 1000 helped |
Dears, I Solved it creating a host folder like this: sudo mkdir -p /srv/docker/jenkins/jenkins |
I solved this problem with don't chmod or chown any folder, just let it be. My environment :
just |
In k8s for volumes you can use securityContext:
|
docker run -it --rm --name jenkins -p 8090:8080 -p 50 000:50000 -v /home/docker/jenkins:/var/jenkins_home csanchez/jenkins-kubernetes after running this command and checking in the browser with http://ip:8090 it is asking for password after installing of jenkins. any suggestions on this |
On Linux below steps worked for me: mkdir $PWD/jenkins sudo chown -R 1000:1000 $PWD/jenkins docker run -d -p 8080:8080 -p 50000:50000 -v $PWD/jenkins:/var/jenkins_home --name jenkins jenkins |
@hemano |
|
I did two things without creating a JENKINS user.
Running docker with privileged helped! |
wow that's a horrible idea |
For the record, use a volume, see the recommended solution a bit more detailed at #493 (comment) I.e. do not try to mount the host into the container, aka bind-mount. This is the way to get hurt, and solve it by a workaround. Using bind-mounts to store production data is really not the way to go. |
Also in-case anyone is as stupid as me. Try to check your $PWD I just got this from a script changing dir into /opt which is root owned. 🤦♂️ |
Do.Not.Use.Bind.Mounts. You will get burnt by all manners of permissions issues. That is expected, and using bind mounts is documented to be wrong. Use volumes Again, see #493 (comment) @carlossg should we lock this issue? |
Actually I think this permission issue can and should be solved by the Jenkins Docker image in the |
mkdir /home/ronit/jenkins_home docker run --privileged --name jenkins-1 -p 8080:8080 -p 50000:50000 -v /home/ronit/jenkins_home:/var/jenkins_home jenkins |
Actually my own was caused by the fact that I have started a container that I killed without removing, docker still saw the container as the owner of the jenkins_home volume. I ran |
Hi all Actually, this issue would take my time a lot. It's a hard issue for a person who has little experiences with Docker that specify relevant to permission of sharing a folder between local and container. As a lucky person, I found a blog on the Media. It helps me to understand the UID and GID, and what is the permission of a user who runs a container. The URL of the block here: https://medium.com/@mccode/understanding-how-uid-and-gid-work-in-docker-containers-c37a01d01cfI am going to show my problems and how can I resolve it. The personal information of OS and Docker version, Dockerfile is used to build and Image
My problemIt is the same in this issue, don't have permission on the /var/jenkins_home. My understanding about the issueFirst, the UID on the local is 502, and with the UID I don't have permission to write on the /private/var/jenkins_home on local, There is permission root here, and as you know on above I changed the owner of /private/var/jenkins_home to UID and GID to 1000. That's reason with the current user role on my local can't write any things into the folder. Got itI create a new folder into my Users folder.
Finally, run container with a new path to mounth
It's work for me. Please feel free to contact me to help our skill is better than. Thank you for reading |
Great, thanks! |
This solution still has problem, if I run |
ERROR ON AWS #INSTANCE### i have tried its working
|
copy_reference_file.log owned by root and not jenkins
The text was updated successfully, but these errors were encountered: