1、安装 Fedora EPEL
yum -y install
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2、安装docker
yum -y install docker-io
[root@localhost ~]# yum -y install docker-io
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink
* base: mirrors.163.com
* epel: mirrors.tongji.edu.cn
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
epel
epel/primary_db
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.7.1-2.el6 will be installed
--> Processing Dependency: libcgroup for package: docker-io-1.7.1-2.el6.x86_64
--> Processing Dependency: lxc for package: docker-io-1.7.1-2.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-24.el6_9 will be installed
---> Package lxc.x86_64 0:1.0.11-1.el6 will be installed
--> Processing Dependency: lua-lxc(x86-64) = 1.0.11-1.el6 for package: lxc-1.0.
--> Processing Dependency: lua-alt-getopt for package: lxc-1.0.11-1.el6.x86_64
--> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.11-1.el6.x
--> Running transaction check
---> Package lua-alt-getopt.noarch 0:0.7.0-1.el6 will be installed
---> Package lua-lxc.x86_64 0:1.0.11-1.el6 will be installed
--> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.11-1.el6.x86
---> Package lxc-libs.x86_64 0:1.0.11-1.el6 will be installed
--> Running transaction check
---> Package lua-filesystem.x86_64 0:1.4.2-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================
Package Arch Version
===============================================================================
Installing:
docker-io x86_64 1.7.1-2.el6
Installing for dependencies:
libcgroup x86_64 0.40.rc1-24.el6_9
lua-alt-getopt noarch 0.7.0-1.el6
lua-filesystem x86_64 1.4.2-1.el6
lua-lxc x86_64 1.0.11-1.el6
lxc x86_64 1.0.11-1.el6
lxc-libs x86_64 1.0.11-1.el6
Transaction Summary
===============================================================================
Install 7 Package(s)
Total download size: 5.1 M
Installed size: 20 M
Downloading Packages:
(1/7): docker-io-1.7.1-2.el6.x86_64.rpm
(2/7): libcgroup-0.40.rc1-24.el6_9.x86_64.rpm
(3/7): lua-alt-getopt-0.7.0-1.el6.noarch.rpm
(4/7): lua-filesystem-1.4.2-1.el6.x86_64.rpm
(5/7): lua-lxc-1.0.11-1.el6.x86_64.rpm
(6/7): lxc-1.0.11-1.el6.x86_64.rpm
(7/7): lxc-libs-1.0.11-1.el6.x86_64.rpm
-------------------------------------------------------------------------------
Total 2.3
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16()
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16(l
2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of mysql-libs
Installing : lxc-libs-1.0.11-1.el6.x86_64
Installing : lua-filesystem-1.4.2-1.el6.x86_64
Installing : lua-lxc-1.0.11-1.el6.x86_64
Installing : lua-alt-getopt-0.7.0-1.el6.noarch
Installing : lxc-1.0.11-1.el6.x86_64
Installing : libcgroup-0.40.rc1-24.el6_9.x86_64
Installing : docker-io-1.7.1-2.el6.x86_64
Verifying : lxc-1.0.11-1.el6.x86_64
Verifying : lua-lxc-1.0.11-1.el6.x86_64
Verifying : lxc-libs-1.0.11-1.el6.x86_64
Verifying : libcgroup-0.40.rc1-24.el6_9.x86_64
Verifying : docker-io-1.7.1-2.el6.x86_64
Verifying : lua-alt-getopt-0.7.0-1.el6.noarch
Verifying : lua-filesystem-1.4.2-1.el6.x86_64
Installed:
docker-io.x86_64 0:1.7.1-2.el6
Dependency Installed:
libcgroup.x86_64 0:0.40.rc1-24.el6_9 lua-alt-getopt.noarch 0
lua-filesystem.x86_64 0:1.4.2-1.el6 lua-lxc.x86_64 0:1.0.11
lxc.x86_64 0:1.0.11-1.el6 lxc-libs.x86_64 0:1.0.1
Complete!
3、启动docker
docker -d
这个时候会报错, 说内核需要升级到3.10.0
后面又提示libdevmapper.so的错误,
需要升级device-mapper-libs
WARN[0000] You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
docker: relocation error: docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference
4、解决libdevmapper.so的错误
yum upgrade device-mapper-libs -y
这个时候,会提示:
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Upgrade Process
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-libs.x86_64 0:1.02.79-8.el6 will be updated
--> Processing Dependency: device-mapper-libs = 1.02.79-8.el6 for package: device-mapper-1.02.79-8.el6.x86_64
---> Package device-mapper-libs.x86_64 0:1.02.117-12.el6_9.1 will be an update
--> Running transaction check
---> Package device-mapper.x86_64 0:1.02.79-8.el6 will be updated
--> Processing Dependency: device-mapper = 1.02.79-8.el6 for package: device-mapper-event-1.02.79-8.el6.x86_64
---> Package device-mapper.x86_64 0:1.02.117-12.el6_9.1 will be an update
--> Running transaction check
---> Package device-mapper-event.x86_64 0:1.02.79-8.el6 will be updated
---> Package device-mapper-event.x86_64 0:1.02.117-12.el6_9.1 will be an update
--> Processing Dependency: device-mapper-event-libs = 1.02.117-12.el6_9.1 for package: device-mapper-event-1.02.117-12.el6_9.1.x86_64
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 0:1.02.79-8.el6 will be updated
---> Package device-mapper-event-libs.x86_64 0:1.02.117-12.el6_9.1 will be an update
--> Processing Conflict: device-mapper-event-1.02.117-12.el6_9.1.x86_64 conflicts lvm2-libs < 2.02.111
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package lvm2-libs.x86_64 0:2.02.100-8.el6 will be updated
--> Processing Dependency: lvm2-libs = 2.02.100-8.el6 for package: lvm2-2.02.100-8.el6.x86_64
---> Package lvm2-libs.x86_64 0:2.02.143-12.el6_9.1 will be an update
--> Running transaction check
---> Package lvm2.x86_64 0:2.02.100-8.el6 will be updated
---> Package lvm2.x86_64 0:2.02.143-12.el6_9.1 will be an update
--> Processing Dependency: device-mapper-persistent-data >= 0.6.2 for package: lvm2-2.02.143-12.el6_9.1.x86_64
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.2.8-2.el6 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.6.2-0.1.rc7.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================
Package Arch Version Repository
Size
===============================================================================
Updating:
device-mapper-libs x86_64 1.02.117-12.el6_9.1 updates 257 k
lvm2-libs x86_64 2.02.143-12.el6_9.1 updates 1.0 M
Updating for dependencies:
device-mapper x86_64 1.02.117-12.el6_9.1 updates 218 k
device-mapper-event x86_64 1.02.117-12.el6_9.1 updates 134 k
device-mapper-event-libs x86_64 1.02.117-12.el6_9.1 updates 126 k
device-mapper-persistent-data x86_64 0.6.2-0.1.rc7.el6 base 463 k
lvm2 x86_64 2.02.143-12.el6_9.1 updates 941 k
Transaction Summary
===============================================================================
Upgrade 7 Package(s)
Total download size: 3.1 M
Downloading Packages:
(1/7): device-mapper-1.02.117-12.el6_9.1.x86_64.rpm | 218 kB 00:00
(2/7): device-mapper-event-1.02.117-12.el6_9.1.x86_64.r | 134 kB 00:00
(3/7): device-mapper-event-libs-1.02.117-12.el6_9.1.x86 | 126 kB 00:00
(4/7): device-mapper-libs-1.02.117-12.el6_9.1.x86_64.rp | 257 kB 00:00
(5/7): device-mapper-persistent-data-0.6.2-0.1.rc7.el6. | 463 kB 00:00
(6/7): lvm2-2.02.143-12.el6_9.1.x86_64.rpm | 941 kB 00:00
(7/7): lvm2-libs-2.02.143-12.el6_9.1.x86_64.rpm | 1.0 MB 00:00
-------------------------------------------------------------------------------
Total 2.3 MB/s | 3.1 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : device-mapper-1.02.117-12.el6_9.1.x86_64 1/14
Updating : device-mapper-libs-1.02.117-12.el6_9.1.x86_64 2/14
Updating : device-mapper-event-libs-1.02.117-12.el6_9.1.x86_64 3/14
Updating : device-mapper-event-1.02.117-12.el6_9.1.x86_64 4/14
Updating : lvm2-libs-2.02.143-12.el6_9.1.x86_64 5/14
Updating : device-mapper-persistent-data-0.6.2-0.1.rc7.el6.x86_64 6/14
Updating : lvm2-2.02.143-12.el6_9.1.x86_64 7/14
Cleanup : lvm2-2.02.100-8.el6.x86_64 8/14
Cleanup : lvm2-libs-2.02.100-8.el6.x86_64 9/14
Cleanup : device-mapper-event-1.02.79-8.el6.x86_64 10/14
Cleanup : device-mapper-event-libs-1.02.79-8.el6.x86_64 11/14
Cleanup : device-mapper-1.02.79-8.el6.x86_64 12/14
Cleanup : device-mapper-libs-1.02.79-8.el6.x86_64 13/14
Cleanup : device-mapper-persistent-data-0.2.8-2.el6.x86_64 14/14
Verifying : lvm2-libs-2.02.143-12.el6_9.1.x86_64 1/14
Verifying : lvm2-2.02.143-12.el6_9.1.x86_64 2/14
Verifying : device-mapper-libs-1.02.117-12.el6_9.1.x86_64 3/14
Verifying : device-mapper-event-1.02.117-12.el6_9.1.x86_64 4/14
Verifying : device-mapper-persistent-data-0.6.2-0.1.rc7.el6.x86_64 5/14
Verifying : device-mapper-event-libs-1.02.117-12.el6_9.1.x86_64 6/14
Verifying : device-mapper-1.02.117-12.el6_9.1.x86_64 7/14
Verifying : device-mapper-1.02.79-8.el6.x86_64 8/14
Verifying : device-mapper-event-libs-1.02.79-8.el6.x86_64 9/14
Verifying : device-mapper-persistent-data-0.2.8-2.el6.x86_64 10/14
Verifying : device-mapper-event-1.02.79-8.el6.x86_64 11/14
Verifying : lvm2-libs-2.02.100-8.el6.x86_64 12/14
Verifying : device-mapper-libs-1.02.79-8.el6.x86_64 13/14
Verifying : lvm2-2.02.100-8.el6.x86_64 14/14
Updated:
device-mapper-libs.x86_64 0:1.02.117-12.el6_9.1
lvm2-libs.x86_64 0:2.02.143-12.el6_9.1
Dependency Updated:
device-mapper.x86_64 0:1.02.117-12.el6_9.1
device-mapper-event.x86_64 0:1.02.117-12.el6_9.1
device-mapper-event-libs.x86_64 0:1.02.117-12.el6_9.1
device-mapper-persistent-data.x86_64 0:0.6.2-0.1.rc7.el6
lvm2.x86_64 0:2.02.143-12.el6_9.1
Complete!
5、重新启动docker
service docker restart
自己还reboot重启了服务器
6、查看docker info
docker info
Containers: 0
Images: 9
Storage Driver: devicemapper
Pool Name: docker-8:2-409573-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: extfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 684.1 MB
Data Space Total: 107.4 GB
Data Space Available: 11.14 GB
Metadata Space Used: 1.135 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.146 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.117-RHEL6 (2016-12-13)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 2.6.32-431.el6.x86_64
Operating System: <unknown>
CPUs: 2
Total Memory: 980.9 MiB
Name: localhost.localdomain
7、 安装测试
这个时候,我们安装一个centos试试
docker pull centos
或者, 安装一个ubuntu
docker pull ubuntu
latest: Pulling from centos
6c5159923047: Pull complete
acec82331181: Pull complete
e74c56fbba84: Pull complete
Digest: sha256:c7330fca6b18219311be4bac27535b5d8e6fa9b77c43605bdfd9e177c291be57
Status: Downloaded newer image for centos:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest e74c56fbba84 2 weeks ago 196.6 MB
: )