Bob
Bob

Reputation: 150

Is there any way to create a write-able volume in non-root docker container?

I have pull an image from Jenkins official docker hub.

But the container I created do not have root permission.

I can't change anything in my share volume inside the container

Here is my running command

docker run -itd -v /home/user/docker:/home/host -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

Is there any way to make this path "/home/host" write-able in the container?

Upvotes: 1

Views: 417

Answers (1)

VonC
VonC

Reputation: 1323653

The Jenkins docker usage does include:

NOTE: Avoid using a bind mount from a folder on the host machine into /var/jenkins_home, as this might result in file permission issues (the user used inside the container might not have rights to the folder on the host machine).

If you really need to bind mount jenkins_home, ensure that the directory on the host is accessible by the jenkins user inside the container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run.

docker run -d -u aKnownUser -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

The alternative is to leave docker create a named volume:

docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

Upvotes: 2

Related Questions