在 CentOS 6.4(64位) 安装 docker.io

Docker.io 是轻量级的“容器引擎+映像仓库”,在LXC(linux轻量级容器)的基础上构建,可以运行任何应用程序。

docker.io的核心层由以下几个部分组成:

1、可执行程序,“/usr/bin/docker”

2、docker.io网站上有一系列创建好的操作系统和应用程序映像

3、AUFS(另一个统一文件系统)来实现文件系统的快照,,文件变化,控制只读或读写的需求。

4、LXC(Linux轻量级容器)

5、Cgroups(各种资源和命名空间的管理)

在本文写作的时候,最新版本是0.5.3,但目前开发很活跃,一些功能和特性可能在新版本中会发生变化。

按下面的步骤安装docker.io:

0、安装CentOS6.x

1、因为selinux和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、配置Fedora EPEL 源

sudo yum install

3、配置hop5.in源

cd /etc/yum.repos.dsudo wget

4、安装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============================================================================================ PackageArchVersionRepositorySize============================================================================================Installing: docker-iox86_640.5.3-4.el6hop51.2 MInstalling for dependencies: kernel-ml-aufsx86_643.10.5-3.el6hop533 M lxcx86_640.8.0-3.el6hop581 k lxc-libsx86_640.8.0-3.el6hop575 kTransaction Summary============================================================================================Install4 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 MB00:03(2/4): kernel-ml-aufs-3.10.5-3.el6.x86_64.rpm| 33 MB00:33(3/4): lxc-0.8.0-3.el6.x86_64.rpm| 81 kB00:00(4/4): lxc-libs-0.8.0-3.el6.x86_64.rpm| 75 kB00:00——————————————————————————————–Total896 kB/s | 34 MB00:39Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : lxc-libs-0.8.0-3.el6.x86_641/4Installing : lxc-0.8.0-3.el6.x86_642/4Installing : kernel-ml-aufs-3.10.5-3.el6.x86_643/4Installing : docker-io-0.5.3-4.el6.x86_644/4Verifying : kernel-ml-aufs-3.10.5-3.el6.x86_641/4Verifying : lxc-0.8.0-3.el6.x86_642/4Verifying : lxc-libs-0.8.0-3.el6.x86_643/4Verifying : docker-io-0.5.3-4.el6.x86_644/4Installed: docker-io.x86_64 0:0.5.3-4.el6Dependency Installed: kernel-ml-aufs.x86_64 0:3.10.5-3.el6lxc.x86_64 0:0.8.0-3.el6lxc-libs.x86_64 0:0.8.0-3.el6Complete![root@localhost ~]#

5、检查安装情况

[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、要想docker正常运行还需要在/etc/fstab里增加cgroup文件系统

[root@localhost ~]# echo “none/sys/fs/cgroupcgroup defaults0 0” >> /etc/fstab

[root@localhost ~]# mount /sys/fs/cgroup

只有重新启动才能挂载/sys/fs/cgroup(因为当前运行的内核不支持cgroup),所以上面挂载的命令也可以不执行,但系统需要重新启动。

相关阅读:

Linux容器技术-LXC相关技术知识介绍

Linux容器技术-LXC创建虚拟机的执行过程分析

利用shell脚本监控LXC应用容器内的应用

Cgroup和LXC(Linux container)安装详解(CentOS 6.2) 系统

Linux容器虚拟技术LXC简明手册

停止每日在车水马龙的市井里忙碌的穿梭,

在 CentOS 6.4(64位) 安装 docker.io

相关文章:

你感兴趣的文章:

标签云: