Prerequisite: already installed docker-ce, run the command docker
command:
sudo docker pull jenkins
mkdir -p ~/dockers/jenkins
cd ~/dockers
sudo docker run --name jenkins01 -p 8081:8080 -p 50000:50000 -v ${PWD}/jenkins:/var/jenkins_home jenkins:latest
Error:
touch: Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Need to modify the directory permissions, because when the local data is mapped, / home / docker / owner of the root directory is jenkins user, the User uid container jenkins 1000
sudo chown -R 1000:1000 ~/dockers/jenkins
sudo docker rm jenkins01
sudo docker run --name jenkins01 -p 8081:8080 -p 50000:50000 -v ${PWD}/jenkins:/var/jenkins_home jenkins:latest
Running for some time, you can see the output of the initialization code
Accessible via a browser http://ip:8081
to enter the initial page, enter the original administrator password
Choose "install the recommended plug-in" or "selected plug-ins to install."
Wait for plug-in installation is complete, then Continue
the next step, enter the Create First Admin User
page to create the first admin user, then click Save and Finish, into jenkins home.
So far, docker version jenkins installation has been completed.
References
- docker run jenkins learn when to start to solve the error part
- Docker Jenkins automated deployment of the main reference
- docker jenkins install the latest version of a Chinese version of the installation interface screenshots