This article is installed in ubuntu environment jenkins, jenkins run docker container,
As for how docker installation, refer to https://www.cnblogs.com/xingyunqiu/p/11584066.html
Jenkins's official website Documentation: https://jenkins.io/zh/doc/
Use command to pull specified files from the image repository, I used here is jenkins: lts this version; other versions if needed
Note that since I was deployed Jenkins based docker containerized, there is no need to install jdk environment
sudo docker pull jenkins/jenkins:lts
Configuring the host is mapped to the directory container, after jenkins some configuration files will be stored in this directory, which can set their own, easy to find and manage the future
Folder set permissions is very important, will not perform error
# Create a directory jenkins_home sudo mkdir / Home / jenkins_home # Set the owner of the directory and the group belongs to, ordinary user default uid is 1000, gid to 1000, chown should change own shorthand, referring to change folder permissions, - R refers to subdirectory throughout the sudo chown -R & lt 1000 : 1000 / Home / jenkins_home
Deployment Jenkins, start the docker mirrored jenkins
sudo docker run -d --name jenkins -p 8070:8080 -p 50000:50000 -u root \ -v /home/jenkins_home:/var/jenkins_home \ -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker \ -v /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7 \ -v /opt:/opt \ -v /etc/timezone:/etc/timezone jenkins/jenkins:lts
Interpretation of the relevant parameters
- D represents running in background mode - name defines a name for the container (hereinafter may be used instead of the container id) - P indicates the port to the host port mapping container - V indicates a directory to directory mapping host vessel - U the root root, use and avoid some of the latter problems execute permission -v / Home / jenkins_home: / var / jenkins_home mapping jenkins_home, the data stored in the host, so that the configuration will not lose its container -v / var / rUN / Docker .sock: / var /run/docker.sock and -v / usr / bin / docker: / usr / bin / docker docker mapped to the host into the container, the container can be used directly in the host docker -v / usr / lib / x86_64-the GNU-Linux / libltdl.so. 7 :. /usr/lib/x86_64-linux-gnu/libltdl.so 7 \ library files needed to run the container docker -v / opt: / opt \ self-installation Some software (such as java / maven / run git ...) / etc /: -v / etc / timezone same time timezone map zone file to ensure that container time zone and host (jenkins containers official website of the time zone is not a China time zone) last Jenkins / Jenkins: LTS is to start mirroring
After the container starts, then the following command to view the initial password
sudo cat /home/jenkins_home/secrets/initialAdminPassword
Follow the steps above jenkins installation was successful, open your browser and enter ip: 8087 address to view a Web page, such as page error prompt has been loaded, it should be jenkins service does not start successfully, manually start the next jenkins container.
sudo docker restart jenkins
Jenkins plug-in management interface ==> http: //192.168.10.*: 8080 / PlugInManager
Jenkins Plugin Manager - Advanced Settings interface ==> http: //192.168.10.*: 8080 / PlugInManager / advanced
Jenkins update the page http: //192.168.10.*:8080/updateCenter
References:
https://www.jianshu.com/p/9018cfa3654b
https://www.cnblogs.com/personblog/archive/2019/05/15/10871440.html