Ubuntu + docker + jenkins detailed installation guide

Recently began to implement the project of automated testing, can not avoid dealing with jenkins such as continuous integration tools, give us today to share with you a simple installation and use of related jenkins

1. Preparing the environment

(1) ubuntu system

(2)docker

(3)jenkins

(4)jdk

2, installation docker

(1)安装 sudo apt-get install -y docker.io

(2) Start docker systemctl start docker    may be provided permanently boot from the start  systemctl enable docker

(3) docker Version or docker -v can view the version, indicating that the installation was successful docker

(4) the installation is complete, when you execute docker run hello-world, you can find local docker start looking for hello-world image, if not, to find from the official repository

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

(5) Search mirrored in the warehouse, such as search ubuntu mirror, Docker Search ubuntu After finding (not necessarily there, it may be necessary to change the warehouse), a pull mirroring docker pull ubuntu

Some large mirror, warehouses and abroad, is very slow. We can set up their own private servers, you can also use some other address.

The world's largest and most well-known public repository is the official Docker Docker Hub, more well-known domestic: Docker Pool, Ali cloud warehouses

(6) Ali cloud repository mirroring service configuration, first registered account on Ali cloud https://www.aliyun.com/, after logging into the console - Select docker container mirror service - the mirroring accelerator - the method in accordance with the above said, can be arranged on ubuntu;

Configuration complete execution docker info | grep http you can see the address of the warehouse just configured the

Docker on the specific use, this is not repeated herein, reference may be

Rookie tutorial https://www.runoob.com/docker/docker-tutorial.html

The official English documents https://docs.docker.com/

Chinese documents http://www.dockerinfo.net/document 

3, install jenkins

Related reference

https://jenkins.io/zh/doc/book/installing/

https://hub.docker.com/r/jenkins/jenkins

(1) preparing a local file, save important content to prevent the vessel from being accidentally destroyed and deleted

mkdir /usr/local/workspace/jenkins;chmod 777 jenkins

(2) performing docker pull and docker run command, starting container, if the command is not a local mirror, automatically pulling from the warehouse

docker pull jenkins/jenkins:lts
lts: Pulling from jenkins/jenkins
9cc2ad81d40d: Pull complete
e6cb98e32a52: Pull complete
ae1b8d879bad: Pull complete
42cfa3699b05: Pull complete
8d27062ef0ea: Pull complete
9b91647396e3: Pull complete
7498c1055ea3: Pull complete
7649b1010bf2: Pull complete
1c3f5e14c681: Pull complete
a204aa63f757: Pull complete
9b57f731dd16: Pull complete
d21f82c5429a: Pull complete
440e5fb06ea6: Pull complete
5d43ca048df2: Pull complete
1421ef7f2b0c: Pull complete
0c2b6150f92f: Pull complete
9e0d2e7a610a: Pull complete
36bd756f5339: Pull complete
e27e28c0b503: Pull complete
Digest: sha256:7cfe34701992434cc08bfd40e80e04ab406522214cf9bbefa57a5432a123b340
Status: Downloaded newer image for jenkins/jenkins:lts

 Start of a container named jenkins, 8080 and 50000 and maps directly to the container port of the machine 8080 and 50,000 ports, corresponding to the local file / usr / local / workspace / jenkins

docker run -p 8080:8080 -p 50000:50000 -v /usr/local/workspace/jenkins:/var/jenkins_home --name jenkins -idt jenkins/jenkins:lts
Unable to find image 'jenkins:latest' locally
latest: Pulling from library/jenkins
55cbf04beb70: Pull complete
1607093a898c: Pull complete
9a8ea045c926: Pull complete
d4eee24d4dac: Pull complete
c58988e753d7: Pull complete
794a04897db9: Pull complete
70fcfa476f73: Pull complete
0539c80a02be: Pull complete
54fefc6dcf80: Pull complete
911bc90e47a8: Pull complete
38430d93efed: Pull complete
7e46ccda148a: Pull complete
c0cbcb5ac747: Pull complete
35ade7a86a8e: Pull complete
aa433a6a56b1: Pull complete
841c1dd38d62: Pull complete
b865dcb08714: Pull complete
5a3779030005: Pull complete
12b47c68955c: Pull complete
1322ea3e7bfd: Pull complete
Digest: sha256:eeb4850eb65f2d92500e421b430ed1ec58a7ac909e91f518926e02473904f668
Status: Downloaded newer image for jenkins:latest
7c0c83b83707e40c879156449ea783a24a984fab9a3105e62b298d3a00ffdfaa

(3) Verify that the installation was successful

Run docker logs -f jenkins view of the container of the console log, see the following information indicates jenkins service starts successfully

Aug 29, 2019 5:49:10 AM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Aug 29, 2019 5:49:10 AM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
Aug 29, 2019 5:49:39 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
Aug 29, 2019 5:49:41 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tools.JDKInstaller
Aug 29, 2019 5:49:41 AM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 45,776 ms

Or docker ps -a | grep jenkins see up, indicates the operating status

docker ps -a | grep jenkins
95e49fb019ce        jenkins              "/bin/tini -- /usr/l…"   6 seconds ago       Up 4 seconds                  0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp   jenkins

4, jenkins

(1) Access jenkins 

http://192.168.1.119:8080 , as prompted to configure password

Page prompts password file location: / var / jenkins_home / secrets / initialAdminPassword, because we have the / var / jenkins_home directory mapped to / usr / local / workspace / jenkins directory of the machine, so the password file in this directory

(2) plug-in installation is recommended, can be based on the interface prompts, wait patiently

Question: I met, the installation of the plug-in, if the refresh time to enter jenkins, the first step after you have finished entering the password, the page has been loaded in the blank, we can not continue to access and search the online information to solve

In the $ JENKINS_HOME / hudson.model.UpdateCenter.xml file, which is /usr/local/workspace/jenkins/hudson.model.UpdateCenter.xml default content below

<? XML Version = '1.1' encoding = 'UTF-. 8'?> 
 <sites> 
   <Site> 
    <ID> default </ ID> 
    <URL> https://updates.jenkins-ci.org/update-center. JSON </ url> 
   </ Site> 
</ sites> 
the url into http://mirror.xmission.com/jenkins/updates/update-center.json
or direct access http://192.168.1.119:8080/pluginManager / advanced
then in the following change my
 

(3) create an administrator account, it can be the interface according to prompts

Question: After logging in, you may see a blank page

Access http://192.168.1.119:8080/ restart logged-in administrator account would be

Guess you like

Origin www.cnblogs.com/happyuu-2019/p/11428712.html