Requirement
Use docker technology to manage Jenkins servers. This avoids repeated installation for multiple deployments and facilitates migration to new servers.
Jenkins docker Image
Https://hub.docker.com/_/jenkins/
Official Jenkins docker Image
Pull image:
Docker pull Jenkins
Image:
docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v /var/jenkins_home jenkins
Install docker Client
Http://www.cnblogs.com/xishuai/p/ubuntu-install-docker.html
Installation command:
Update the package index and add a software package that uses HTTPS transmission and a CA certificate.
$ sudo apt-get update$ sudo apt-get install apt-transport-https ca-certificates
Add the GPG key of the official docker software source (verify the validity of the downloaded software package ).
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Tosource.list
The following table lists the apt sources for different Ubuntu and Debian versions.
Operating system version |
Repo |
Precise 12.04 (LTs) |
deb https://apt.dockerproject.org/repo ubuntu-precise main |
Trustash 14.04 (LTs) |
deb https://apt.dockerproject.org/repo ubuntu-trusty main |
Xenial 16.04 (lsts) |
deb https://apt.dockerproject.org/repo ubuntu-xenial main |
Debian 7 wheezy |
deb https://apt.dockerproject.org/repo debian-wheezy main |
Debian 8 Jessie |
deb https://apt.dockerproject.org/repo debian-jessie main |
Debian stretch/Sid |
deb https://apt.dockerproject.org/repo debian-stretch main |
Use the following command to add the apt sourcesource.list
(Replace<REPO>
):
$ echo "<REPO>" | sudo tee /etc/apt/sources.list.d/docker.list
Update the cache of the apt software package.
$ sudo apt-get update
After everything is ready, you can install the latest docker version. The package name isdocker-engine
.
$ sudo apt-get install docker-engine
If the old version of docker (lxc-docker
,docker.io
), Will prompt whether to delete first, select YES.
Set domestic image sources
Docker pull Jenkins is used to find that the running speed is very slow.
Switch the image source to the domestic address.
Https://www.daocloud.io/mirror#accelerator-doc
Linux
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
This script can add -- registry-mirror to your docker configuration file/etc/docker/daemon. JSON. It is applicable to ubuntu14.04, Debian, centos6, centos7, fedora, arch Linux, and opensuse leap 42.1. Other versions may be slightly different. For more details, see the document.
Running Effect
Run:
docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v /var/jenkins_home jenkins
Console:
Visit the Jenkins Website:
Docker is so easy.
Run the Jenkins service using the Jenkins docker Image