Install docker. io in CentOS 6.4

Source: Internet
Author: User
Tags docker run

Install docker. io in CentOS 6.4

Docker. io is a lightweight "container engine + image repository" built on LXC (linux lightweight container) and can run any application.

The docker. io core layer consists of the following parts:

1. executable program: "/usr/bin/docker"

2. The docker. io website has a series of created operating systems and application images.

3. AUFS (another Unified File System) is used to implement snapshot and file changes of the file system and control the read-only or read/write requirements.

4. LXC (Linux lightweight container)

5. Cgroups (management of various resources and namespaces)

At the time of writing this article, the latest version is 0.5.3, but it is currently very active, and some functions and features may change in the new version.

Follow these steps to install docker. io:

0. Install centos6.x

1. Disable selinux because selinux conflicts with LXC.

[root@localhost ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#       enforcing - SELinux security policy is enforced.#       permissive - SELinux prints warnings instead of enforcing.#       disabled - SELinux is fully disabled.SELINUX=disabled# SELINUXTYPE= type of policy in use. Possible values are:#       targeted - Only targeted network daemons are protected.#       strict - Full SELinux protection.SELINUXTYPE=targeted

2. Configure the Fedora EPEL Source

sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

3. Configure the ingress 5.in Source

cd /etc/yum.repos.dsudo wget http://www.hop5.in/yum/el6/hop5.repo

4. Install docker-io

[root@localhost ~]# yum install docker-ioLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: kartolo.sby.datautama.net.id * extras: centos.excellmedia.net * updates: centos.excellmedia.netSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package docker-io.x86_64 0:0.5.3-4.el6 will be installed--> Processing Dependency: lxc >= 0.8.0 for package: docker-io-0.5.3-4.el6.x86_64--> Processing Dependency: kernel-ml-aufs >= 3.10.5 for package: docker-io-0.5.3-4.el6.x86_64--> Running transaction check---> Package kernel-ml-aufs.x86_64 0:3.10.5-3.el6 will be installed---> Package lxc.x86_64 0:0.8.0-3.el6 will be installed--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.8.0-3.el6.x86_64--> Running transaction check---> Package lxc-libs.x86_64 0:0.8.0-3.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================ Package                   Arch              Version                  Repository       Size============================================================================================Installing: docker-io                 x86_64            0.5.3-4.el6              hop5            1.2 MInstalling for dependencies: kernel-ml-aufs            x86_64            3.10.5-3.el6             hop5             33 M lxc                       x86_64            0.8.0-3.el6              hop5             81 k lxc-libs                  x86_64            0.8.0-3.el6              hop5             75 kTransaction Summary============================================================================================Install       4 Package(s)Total download size: 34 MInstalled size: 159 MIs this ok [y/N]: yDownloading Packages:(1/4): docker-io-0.5.3-4.el6.x86_64.rpm                              | 1.2 MB     00:03     (2/4): kernel-ml-aufs-3.10.5-3.el6.x86_64.rpm                        |  33 MB     00:33     (3/4): lxc-0.8.0-3.el6.x86_64.rpm                                    |  81 kB     00:00     (4/4): lxc-libs-0.8.0-3.el6.x86_64.rpm                               |  75 kB     00:00     --------------------------------------------------------------------------------------------Total                                                       896 kB/s |  34 MB     00:39     Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction  Installing : lxc-libs-0.8.0-3.el6.x86_64                                              1/4   Installing : lxc-0.8.0-3.el6.x86_64                                                   2/4   Installing : kernel-ml-aufs-3.10.5-3.el6.x86_64                                       3/4   Installing : docker-io-0.5.3-4.el6.x86_64                                             4/4   Verifying  : kernel-ml-aufs-3.10.5-3.el6.x86_64                                       1/4   Verifying  : lxc-0.8.0-3.el6.x86_64                                                   2/4   Verifying  : lxc-libs-0.8.0-3.el6.x86_64                                              3/4   Verifying  : docker-io-0.5.3-4.el6.x86_64                                             4/4 Installed:  docker-io.x86_64 0:0.5.3-4.el6                                                            Dependency Installed:  kernel-ml-aufs.x86_64 0:3.10.5-3.el6               lxc.x86_64 0:0.8.0-3.el6                lxc-libs.x86_64 0:0.8.0-3.el6                     Complete![root@localhost ~]#

5. Check the installation status.

[root@localhost ~]# docker -hUsage of docker:  -D=false: Debug mode  -H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use  -api-enable-cors=false: Enable CORS requests in the remote api.  -b="": Attach containers to a pre-existing network bridge. Use 'none' to disable container networking  -d=false: Daemon mode  -dns="": Set custom dns servers  -g="/var/lib/docker": Path to graph storage base dir.  -p="/var/run/docker.pid": File containing process PID  -r=false: Restart previously running containers

6. To run docker properly, you must add the cgroup File System in/etc/fstab.

[root@localhost ~]# echo "none                    /sys/fs/cgroup          cgroup  defaults        0 0" >> /etc/fstab[root@localhost ~]# mount /sys/fs/cgroup

You can mount/sys/fs/cgroup only after a restart (because the currently running kernel does not support cgroup). Therefore, the commands mounted above can be not executed, but the system needs to be restarted.

7. restart the system and select "3.10.5-3. el6.x86 _ 64 ".

8. After the system is started, confirm the currently running kernel

[root@localhost ~]# uname -r3.10.5-3.el6.x86_64[root@localhost ~]# grep aufs /proc/filesystems nodev   aufs

9. Run docker. io in daemon mode (in a new terminal)

[root@localhost ~]# docker -d 2013/08/21 07:47:07 WARNING: Your kernel does not support cgroup swap limit.2013/08/21 07:47:07 Listening for HTTP on /var/run/docker.sock (unix)

10. Output hello world in the centos6.4 container

[root@localhost ~]# docker run centos:6.4 echo "hello world"2013/08/21 07:48:41 POST /v1.4/containers/create2013/08/21 07:48:41 POST /v1.4/containers/c6bc9e80097e/start2013/08/21 07:48:41 POST /v1.4/containers/c6bc9e80097e/attach?logs=1&stderr=1&stdout=1&stream=1hello world

11. Test ping from the container

[root@localhost ~]# docker -dns '8.8.8.8' run centos:6.4 ping -c 3 yahoo.com2013/08/21 08:02:15 POST /v1.4/containers/create2013/08/21 08:02:15 POST /v1.4/containers/c40a1244f9bc/start2013/08/21 08:02:15 POST /v1.4/containers/c40a1244f9bc/attach?logs=1&stderr=1&stdout=1&stream=1PING yahoo.com (98.138.253.109) 56(84) bytes of data.64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_seq=1 ttl=48 time=323 ms64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_seq=2 ttl=48 time=329 ms64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_seq=3 ttl=49 time=302 ms--- yahoo.com ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 2304msrtt min/avg/max/mdev = 302.032/318.318/329.656/11.807 ms

Common Errors:

"DNS/Networking Errors inside the docker"

[root@localhost ~]# docker -dns="8.8.8.8" run centos:6.4 yum install hiphop-php2013/08/21 07:53:05 POST /v1.4/containers/create2013/08/21 07:53:05 POST /v1.4/containers/6d9fef14bd1a/start2013/08/21 07:53:05 POST /v1.4/containers/6d9fef14bd1a/attach?logs=1&stderr=1&stdout=1&stream=1Loaded plugins: fastestmirrorError: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try againCould not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

You can run the following command to reset the running environment of docker to solve the above problem.

pkill dockeriptables -t nat -Fifconfig docker0 downbrctl delbr docker0docker -d

Thanks to sciurus for their hard work in creating kernel-ml-aufs related files.

Http://www.oschina.net/translate/nstalling-dockerio-on-centos-64-64-bit? Cmp

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.