Running Jenkins in a Docker container

I want to run Jenkins in a Docker container on Centos7. I saw the official Jenkins documentation: First pull the official Jenkins image from the Docker repository.

docker pull jenkins 

Then start the container using this image and map the data directory to the container with the host; for example, in the example below, / var / jenkins _home from the container is mapped to the jenkins / directory from the current path on the host. The Jenkins 8080 port is also available for the host as 49001.

 docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins 

But when I try to start the docker container, I get the following error:

 /usr/local/bin/jenkins.sh: line 25: /var/jenkins_home/copy_reference_file.log: Permission denied 

Can someone tell me how to fix this problem?

+7
source share
2 answers

The official image of Dener Jenkins in the Docker file . So, all you have to do is make sure the $PWD/jenkins is its own UID 1000 :

 mkdir jenkins chown 1000 jenkins docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins 
+16
source

The latest Jenkins documentation says that Docker uses volumes. Docker is rather complicated in this, the difference between them is the full path name with the -v option for binding and just the name for the volumes.

 docker run -d -p 49001:8080 -v jenkins-data:/var/jenkins_home -t jenkins 

This command will create a docker volume named "jenkins-data" and you will no longer see an error.

Link for managing volumes: https://docs.docker.com/storage/volumes/

0
source

Source: https://habr.com/ru/post/1240272/


All Articles