CentOS 6.5 Installation Docker and Jenkins detailed

Source: Internet
Author: User
Tags commit centos iptables docker run

As a result of the company's project requirements, let me today to Docker and Jenkins set up, I have to build success, the problems encountered therein and the solution recorded to share to everyone.
System: CentOS 6.5 (64-bit)
1. See if the kernel is 3.10 first
Uname-r

If not 3.10, execute the following command:
RPM--import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
RPM-IVH http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

Install Kernel-lt (lt=long-term)
Yum--enablerepo=elrepo-kernel Install Kernel-lt-y
or install kernel-ml (ml=mainline)
Yum--enablerepo=elrepo-kernel Install Kernel-ml-y

PS: Please select the kernel above according to your needs.

Edit grub.conf file, modify grub boot order
# grub.conf generated by Anaconda
#
# so you don't have to rerun grub after making changes to this file
# notice:you have a/boot partition. This is means that
# all kernel and INITRD paths are relative to/boot/, eg.
# root (hd0,0)
# kernel/vmlinuz-version RO root=/dev/mapper/volgroup-lv_root
# initrd/initrd-[generic-]version.img
#boot =/DEV/SDA
Default=0
Timeout=5
Splashimage= (hd0,0)/grub/splash.xpm.gz
Hiddenmenu
Title CentOS (3.10.94-1.el6.elrepo.x86_64)
Root (hd0,0)
kernel/vmlinuz-3.10.94-1.el6.elrepo.x86_64 ro root=/dev/mapper/volgroup-lv_root rd_NO_LUKS LANG=en_US.  UTF-8 rd_no_md rd_lvm_lv=volgroup/lv_swap Sysfont=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root keyboardtype=pc keytable=us rd_no_dm RHGB quiet
Initrd/initramfs-3.10.94-1.el6.elrepo.x86_64.img
Title CentOS (2.6.32-431.el6.x86_64)
Root (hd0,0)
kernel/vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/volgroup-lv_root rd_no_luks LANG=en_US.  UTF-8 rd_no_md rd_lvm_lv=volgroup/lv_swap Sysfont=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root keyboardtype=pc keytable=us rd_no_dm RHGB quiet
Initrd/initramfs-2.6.32-431.el6.x86_64.img


Verify where the kernel is just installed, then set the default value (starting at 0), and the new installed kernel is in the first place. So set default=0

2. Install Docker
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RPM-IVH epel-release-6-8.noarch.rpm
Yum-y Install docker-io*
Service Docker start
Chkconfig Docker on

If you start Docker, you receive the following error:
/usr/bin/docker:relocation Error:/usr/bin/docker:symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

Please execute the following command:
Yum Install Device-mapper-event-libs

If there is no problem, let's verify the next Docker and execute the following command:
Docker--version
Docker version 1.7.1, build 786b29d/1.7.1

I'm showing the 1.7.1 version here. OK, we can use Docker to install the Jenkins.

3.docker Installation Jenkins
Docker Pull Jenkinsci/jenkins

PS: Because our project has designated this

If the following error occurs:
Unable to get remote Tags:get https://registry-1.docker.io/v1/repositories/library/jenkins/tags:dial TCP 218.93.250.18:443:connection timed out

Please perform:
Dig Index.docker.io +noall +answer +nocomments
I see here are 3 IP, as follows:
; <<>> DiG 9.8.2rc1-redhat-9.8.2-0.37.rc1.el6_7.5 <<>> index.docker.io +noall +answer + Nocomments
;; Global options: +cmd
Index.docker.io. 251 in CNAME Elb-io.us-east-1.aws.dckr.io.
Elb-io.us-east-1.aws.dckr.io. 530 in CNAME us-east-1-elbio-rm5bon1qaeo4-623296237.us-east-1.elb.amazonaws.com.
Us-east-1-elbio-rm5bon1qaeo4-623296237.us-east-1.elb.amazonaws.com in A 54.164.250.255
Us-east-1-elbio-rm5bon1qaeo4-623296237.us-east-1.elb.amazonaws.com in A 54.152.78.181
Us-east-1-elbio-rm5bon1qaeo4-623296237.us-east-1.elb.amazonaws.com in A 52.0.10.162

I picked a random IP to add to the hosts.
Echo ' 54.208.179.150 Registry-1.docker.io ' >>/etc/hosts

And then execute it again.
Docker Pull Jenkinsci/jenkins

If the download succeeds, we will verify that:
Docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
Jenkinsci/jenkins latest bbb3fdd65bef 3 days ago 882.6 MB

The ps:docker images instruction can query the list of the mage which has been pull back to the present and the simple information?
Okay, then we'll start Jenkins:
Docker run-d-P 8080:8080 jenkinsci/jenkins
If you start by reporting the following error:
Cannot start container f12cdd095c6fcfc759e7986276b49d3647e02cc50e55ce9cf1559ed249617281:iptables failed:iptables-t Nat-a docker-p tcp-d 0/0--dport 8080-j dnat--to-destination 172.17.0.8:8080! -I docker0:iptables:No Chain/target/match by that name.\n (exit status 1)

Solution:

*nat
:P rerouting ACCEPT [27:11,935]
: INPUT ACCEPT [0:0]
: OUTPUT ACCEPT [598:57,368]
:P ostrouting ACCEPT [591:57,092]
:D Ocker-[0:0]
-A prerouting-m addrtype--dst-type local-j Docker
-A OUTPUT! -D 127.0.0.0/8-M addrtype--dst-type Local-j Docker
-A postrouting-s 172.17.0.0/16! -O Docker0-j Masquerade
COMMIT
*filter
: INPUT ACCEPT [139,291:461,018,923]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [127,386:5,251,162]
:D Ocker-[0:0]
-A input-m state--state related,established-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-p tcp-m state--state new-m TCP--dport 22-j ACCEPT
-A input-p tcp-m state--state new-m TCP--dport 8080-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
-A forward-o docker0-j Docker
-A forward-o docker0-m conntrack--ctstate related,established-j ACCEPT
-A forward-i Docker0! -O docker0-j ACCEPT
-A forward-i docker0-o docker0-j ACCEPT
COMMIT

Then save the exit and restart the iptables. Jenkins:
Docker run-d-P 8080:8080 jenkinsci/jenkins

Then verify in the browser:
http://ip:8080

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.