Installing Jenkins on docker of Ci and CD


1、 Introduction of Ci, CD, Jenkins

CI: continuous integration In the traditional software development environment, there is integration, but there is no continuous integration. For a long time, branches are separated from the trunk, which may lead to a large deviation between the branches and the trunk. When integrating code, it may take several hours to repair the code, so as to integrate the code into the trunk (commonly known as “integration hell” or “integration disaster”) Encourage team members to conduct frequent integration (such as once every hour or at least once a day) to avoid this situation. Through the process of automatic detection, pulling, building and (in most cases) unit testing, the quality of code can be ensured and can be used in the next step. This is also the purpose of continuous integration. CI is the automated process of developers.
CD: continuous delivery and continuous deployment. Here are some materials and a brief summary:
1. Continuous delivery means that all changes can be delivered to production at any time, emphasizing a deliverable capability

2. Continuous deployment means that all the changes that have been found and passed all quality tests will be automatically deployed to the production environment, which emphasizes a way


Jenkins: Jenkins is the leader of open source CI & CD software, and has many plug-ins to support it to build / test software projects continuously and automatically, and monitor the running of external tasks

2、 Installing Jenkins on docker

Select the Jenkins image file. Jenkinsci / BlueOcean is recommended here. The image contains the current long-term support (LTS) version of Jenkins (which can be put into use). All blue ocean plug-ins and functions are bundled. This means that you don’t need to install the blue ocean plug-in separately

docker run \
  -u root \
  --rm \
  -d \
  -p 8083:8080 \
  -p 50000:50000 \
  -v /data/jenkins:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \

Parameter Description:

–The docker container is automatically deleted when RM is closed (the following figure shows an example). If you need to quit Jenkins, this can keep you clean;
-D run the container in the background;
-P maps port 8080 of container service to port 8090 of host computer (my 8080 has been occupied by Apollo, so it can be changed to 8083. It is found that many tools like to use port 8080, such as Apollo, skywalking, and Jenkins, etc.) port. The same is true for port 50000 on the lower side, which maps port 50000 of the container to port 50000 on the host;
-V here is / var / Jenkins where you mount the local ‘/ data / Jenkins’ directory into the container_ In home, as the storage directory of Jenkins; / var / run/ docker.sock Represents the UNIX based socket that the docker daemons listen through. This mapping allows the jenkinsci / BlueOcean container to communicate with the docker daemons.
Jenkinsci / BlueOcean is the image name
When docker runs, if the image file does not exist, the image will be automatically pulled first, and then the container will be started. The following figure shows that the image does not exist locally, and then the process of automatic pulling is displayed

After the installation is completed, open a browser to access: http: / / deployed machine IP: 8083 (the default is 8080 if there is no change). You can see the Jenkins interface


Then access the Jenkins console log through the following command and copy the password (the generated administrator password is between the two groups of asterisks), as shown in the figure below
docker logs


After copying the password, follow the page prompts, paste it in the past, and click continue to enter the next step

Click here to install the recommended plug-in and wait for the installation to complete
After the plug-in installation is completed, you can create a user or continue to use admin according to the prompt. After that, by default, click save and finish to enter the home page of Jenkins
At this point, the Jenkins deployment process has ended. Here are two more commands that may be used:

1. Access the Jenkins / Blue Ocean docker container

docker exec -it  bash

2. Access the Jenkins console log

docker logs
The above access administrator password is to use this command, deployment down is very fast, let’s try it!