Reputation: 416
I want to extend the Jenkins official image, and land my mercurial repo in /var/jenkins_home
, which is how I source control my configs on Jenkins without docker. But when I do:
USER root
ADD src/hgrc /var/jenkins_home/.hg/hgrc
RUN chown jenkins:jenkins /var/jenkins_home/.hg/hgrc
It keeps hgrc as 501:dialout, which appears to be related to the fact that /var/jenkins_home
is a volume in the jenkins image.
Or even if I just do:
USER jenkins
WORKDIR /var/jenkins_home
RUN hg init
The folder /var/jenkins_home/.hg
doesn't get created like it would usually. In the first example, an .hg
gets created if it doesn't exist, but it is owned by root.
So what's the "right" way to land files in that volume created by an upstream image?
Upvotes: 2
Views: 1963
Reputation: 1901
The details provided here are not sufficient to understand the problem as is. But looking at the gist, I could relate to your problem. It would mostly related to the file permission related issues for mounted volumes.
The mounted volumes will receive the credentials based on the original base folder UID and GID. Same uid and gid will get propagated to the container.
To overcome such a problem you may have two options:
If you can change the file permissions of the parent folder used for mounting. Then, update the parent folder which is used for mounting to have the uid and gid as that of the uid and gid of the jenkins user within docker container.
You would need to follow this approach if you have control on the docker image generation script and don't have access to change the uid and gid of the parent folder which you are mounting. Synchronize the uid, gid of the key user (the user who is running the demon process within the docker container, in your case, it could be jenkins user) with the uid and gid of the parent folder.
The easiest way would be to follow the first approach.
You can refer to the similar problem I faced, and resolved as per : nfs volume mount to mysql docker container inside a ubuntu virtualbox fail
Upvotes: 3