- Ps :(Jenkins is a java-based tool so you need to install JDK first)
docker pull jenkins/jenkins
Copy the code
Create Jenkins mount directory /var/jenkins_home on the server and grant permissions. Then mount Jenkins container directory to this directory, so that we can easily modify the configuration file in the container. If we don’t do this, then if we need to modify the container configuration file, it will be a bit troublesome, because although we can use docker exec-it –user root container id /bin/bash to access the container directory, we can’t even use the simple vi command.)
mkdir -p /var/jenkins_home
Copy the code
chmod 777 /var/jenkins_home
Copy the code
3. Create and start the Jenkins container
docker run -d -p 10240:8080 -p 10241:50000 \ -v /var/jenkins_home:/var/jenkins_home \ -v /etc/localtime:/etc/localtime \ --name myjenkins jenkins/jenkinsCopy the code
-d Run the image in the background
-p 10240:8080 Maps port 8080 of the mirror to port 10240 of the server.
-p 10241:50000 Maps port 50000 of the mirror to port 10241 of the server
-v /var/jenkins_home:/var/jenkins_home is the Jenkins working directory of the container. We mounted a directory on the hard disk to this directory to facilitate the use of the original working directory after updating the image. Here we set up the /var/jenkins_home directory we created above
– v/etc/localtime: / etc/localtime let containers and servers the same time Settings.
–name myJenkins Give the container an alias
4. Check whether Jenkins is successfully started
docker ps -l
Copy the code
5. View docker container logs.
docker logs myjenkins
Copy the code
6. Enable image acceleration and go to the CD /var/jenkins_home/ directory.
cd /var/jenkins_home/
Copy the code
vi hudson.model.UpdateCenter.xml
Copy the code
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
Modify the vi Hudson. Model. UpdateCenter. The content of the XML
Change the URL to the official image of Tsinghua University:Mirrors.tuna.tsinghua.edu.cn/jenkins/upd…
7. Visit the Jenkins page and enter your IP plus 10240
8. To obtain the administrator password, edit the initialAdminPassword file to view and enter the password in the login password to start using.
vi /var/jenkins_home/secrets/initialAdminPassword
Copy the code
PS: It would be nice if it were not in Chinese