Software name or operating system version Download address
CentOS 7.2 
Docker 19.03.5, build 633 a0ea One click to download

Description:

The Jenkins Docker image needs to be obtained directly from the official website. The unofficial docker may lead to subsequent plug-in installation problems because the Jenkins version is too low.

First, pull the mirror image

URL: Jenkins Download and Deployment

2. Pull the mirror according to the official command

docker pull jenkins/jenkins:lts
Copy the code

Iii. Check whether the Jenkins version in the Docker image is the latest version

Docker inspect docker_container_id Example: Docker inspect 308d3DF85eabCopy the code

Create a directory

After the image is pulled, create the corresponding directory, modify the permission, and view the image information, as shown in the following figure:

mkdir /var/jenkins
chmod -R 777 /var/jenkins
Copy the code

5. Start the container

 docker run -itd -p 8080:8080 -p 50000:50000 --restart always -v /var/jenkins:/var/jenkins_home --name jenkins jenkins/jenkins:lts
Copy the code

6. Check the startup status based on logs

docker logs -f jenkins
Copy the code

7, find the initial password of admin, and copy start

URL: http://your IP: port

Here my URL is: http://10.8.14.41:8080

Since the initial process is over, borrow the screenshot from others, as shown below:

The figure shows that Jenkins has been successfully started and is waiting for initialization. It is necessary to find the initial password of the administrator and fill it in the address bar to start the initialization.

There are several methods to obtain the administrator initial password: 1. Enter the container according to the path to find the docker exec - it Jenkins/bin/bash cat/var/jenkins_home/secrets/initialAdminPassword 2. In the mount to the outside of the container's host machine directory to find the cat/var/Jenkins/secrets/initialAdminPassword 3. The Jenkins startup log just showed that this string of passwords was checked and displayed in the step of viewing the startup status through the logCopy the code

After completion, wait for a short time to enter the following page:

8. Select the recommended plug-in to install the system

If any plug-in is not installed, try again.

[continue as admin] [continue as admin] [continue as admin] [continue as admin]

When finally done, the following image appears:

So far, the Docker mode of Jenkins 2.x has been completely installed.