通过下面命令可以安装docker 下的jenkins
默认jenkins是使用1000 的uid,所以,宿主机maping的目录权限要改成1000 sudo chown -R 1000:1000 /home/jenkins-data:/var/jenkins_home
sudo docker run --name jenkins-production -d -p 5000:5000 -p 8080:8080 -v /home/jenkins-data:/var/jenkins_home -it --restart always --privileged=true jenkins/jenkins
How to run and upgrade Jenkins using the official Docker image
Fri, Sep 7, 2018#ci #jenkins #docker #upgrade
For some time now, I’ve been trying to follow and answer questions arising in the official Git repository for the Docker image of Jenkins.
I have especially been trying to encourage people to move away from using bind mounts [1] and prefer volumes instead.
Ideally, you never restart a container. You just start a new one from the same (or another) image.
Anything you want to keep has to be in the declared volume(s), that is all you need.
Tip | jenkins/jenkins is the official repository on Docker Hub for the Jenkins Project. The jenkins and jenkinsci/jenkins images are deprecated. |
I suspect you’ve come here just to copy and paste commands and move on. We all do :).
So, here you are. Let’s imagine I want to run Jenkins 2.107.3, here is how you would do it for simple production usage.
docker volume create jenkins-data
docker run --name jenkins-production \
--detach \
-p 50000:50000 \
-p 8080:8080 \
-v jenkins-data:/var/jenkins_home \
jenkins/jenkins:2.107.3
# If run for the first time, just run the following to get the admin
# password once it has finished starting
docker exec jenkins-production bash -c 'cat $JENKINS_HOME/secrets/initialAdminPassword'Using Docker, upgrading should always just be a matter of using a more recent version of the image.
Jenkins follows this pattern, so if I want to upgrade to latest Jenkins LTS to date, 2.121.3, all I have to do is the following. You will notice that we do use the exact same command as above, but we’ve just updated the version to the one we want to upgrade to:
docker stop jenkins-production
docker rm jenkins-production # just temporarily docker rename it instead if that makes you worried
docker run --name jenkins-production \
--detach \
-p 50000:50000 \
-p 8080:8080 \
-v jenkins-data:/var/jenkins_home \
jenkins/jenkins:2.121.3Done.
— Baptiste Mathus
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!