Docker installs the latest version of Jenkins

Time:2020-11-30

1、 Pull the Jenkins image and use the following command to install the latest version. Without the version number, it is not the latest version. Many plug-ins cannot be installed. In docker environment, it is more troublesome to upgrade the Jenkins version.

docker pull jenkins/jenkins:lts

be careful:If the installation is time-consuming or cannot be pulled down, configuring docker to obtain the image’s alicloud address can speed up the image download. The configuration steps and contents are as follows:

vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://fy707np5.mirror.aliyuncs.com"]
}

Then save and exit.

2、 Pull the image and pull the image successfully, as shown in the figure:

Docker installs the latest version of Jenkins

1. You can use the command to check whether the image exists

docker images

Docker installs the latest version of Jenkins

be careful:Tag means version number, Jenkins latest version number LTS

2. View Jenkins details

docker inspect [IMAGE ID]

be careful:[image ID] image ID in image

Docker installs the latest version of Jenkins

3、 Create a data mount directory (ensure that the data can be recovered after the service is mounted)

#Create data mount directory
mkdir /home/data/jenkins_home
#The data directory is authorized. Otherwise, an error is reported. There is no such file directory
chmod 777 /home/data/jenkins_home/

4、 Start the Jenkins container

sudo docker run -itd -p 2080:8080 -p 50000:50000 --name jenkins --privileged=true  -v /home/data/jenkins_home:/var/jenkins_home  jenkins/jenkins:lts

Command interpretation:

-ITD: running in the background
 -p: Mapping port host port: container port
 -v: Mount Host Directory: container directory
 --Name: Custom container name
 --Privileged: with this parameter, the root in the container has the true root authority. Otherwise, the root in the container is just an external ordinary user. The privileged started D container can see many devices on the host, and can mount, and even allow you to start the docker container in the docker container.
              : image name

To check whether the startup is successful, use the following command:

#View containers all containers
docker ps -a
​
#View running containers
docker ps

5、 Enter IP + port (the server address of IP deployment Jenkins, the port is the host port in the command) in the browser. After a long wait, enter the following page:

Docker installs the latest version of Jenkins

The administrator password is required here. The password is in the Jenkins container. Use the command to obtain the initial password of the administrator

#[image ID] the image ID of the container
docker exec -it [IMAGE ID] bash
​
#Get the password by command
cat /var/jenkins_home/secrets/initialAdminPassword

Docker installs the latest version of Jenkins

Input the password into the administrator password box and click continue to display the following page:

Docker installs the latest version of Jenkins

6、 If you use it for the first time, it is recommended to install the recommended plug-in, and then go to the following page to wait for installation

Docker installs the latest version of Jenkins

7、 After installation, click continue to enter the following page, create an account, click save and finish, or continue with the admin account.

Docker installs the latest version of Jenkins

1. Go to the following page:

Docker installs the latest version of Jenkins

2. Click save and finish to enter the following page:

Docker installs the latest version of Jenkins

3. Click to start using Jenkins

Docker installs the latest version of Jenkins

This is the end of Jenkins installation

8、 Some people may feel uncomfortable looking at English. They can install Chinese plug-ins to solve the problem

1. Enter the manager Jenkins menu

2. Enter the global tool configuration menu, select the red area, click apply, and then click save.

Docker installs the latest version of Jenkins

3. Enter manager Jenkins and click on the manager plugins menu

Docker installs the latest version of Jenkins

4. Click the optional plug-in, search for localization: Chinese (Simplified) in the filter, and click Install directly. After the installation is completed, it will be found in the installed.

Docker installs the latest version of Jenkins

5. After the installation, restart Jenkins. When you enter the page, Chinese will be displayed, as shown in the figure:

Docker installs the latest version of Jenkins

Author: Soul Hau Xuan welcome public official account.Docker installs the latest version of Jenkins

I reserve all rights and interests, please indicate the source.
Friends with stories and ideas are welcome to share with me. You can send them to e-mail: [email protected]