Docker如何安装与卸载
这篇文章将为大家详细讲解有关Docker如何安装与卸载,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
目前创新互联已为成百上千的企业提供了网站建设、域名、虚拟主机、网站托管、企业网站设计、沙坪坝网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
准备工作
系统:centos6.x
安装
1. 关闭seLinux
vim /etc/selinux/config
修改后的值: SELINUX=disabled
# 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
查看状态:sestatus
状态不为disabled,则重启
[root@iZwz9eczt2tstmhvm8mv25Z docker]# sestatus SELinux status: disabled [root@iZwz9eczt2tstmhvm8mv25Z docker]#
2. 安装epel源
下载wget http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm --2017-04-25 09:55:43-- http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm 正在解析主机 ftp.riken.jp... 134.160.38.1 正在连接 ftp.riken.jp|134.160.38.1|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:14540 (14K) [text/plain] 正在保存至: “epel-release-6-8.noarch.rpm” 100%[======================================>] 14,540 43.5K/s in 0.3s 2017-04-25 09:55:46 (43.5 KB/s) - 已保存 “epel-release-6-8.noarch.rpm” [14540/14540]) [root@iZwz9eczt2tstmhvm8mv25Z docker]# ls epel-release-6-8.noarch.rpm [root@iZwz9eczt2tstmhvm8mv25Z docker]#
安装rpm -ivh epel-release-6-8.noarch.rpm
[root@iZwz9eczt2tstmhvm8mv25Z docker]# rpm -ivh epel-release-6-8.noarch.rpm warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release warning: /etc/yum.repos.d/epel.repo created as /etc/yum.repos.d/epel.repo.rpmnew ########################################### [100%] [root@iZwz9eczt2tstmhvm8mv25Z docker]#
3. 安装lxc与libcgroup
yum install lxc libcgroup
[root@iZwz9eczt2tstmhvm8mv25Z docker]# yum install lxc libcgroup Loaded plugins: security base | 3.7 kB 00:00 epel | 4.3 kB 00:00 epel/primary_db | 5.9 MB 00:05 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 803 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package libcgroup.x86_64 0:0.40.rc1-23.el6 will be installed ---> Package lxc.x86_64 0:1.0.9-1.el6 will be installed --> Processing Dependency: lua-lxc(x86-64) = 1.0.9-1.el6 for package: lxc-1.0.9-1.el6.x86_64 --> Processing Dependency: lua-alt-getopt for package: lxc-1.0.9-1.el6.x86_64 --> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.9-1.el6.x86_64 --> 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.9-1.el6 will be installed --> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.9-1.el6.x86_64 ---> Package lxc-libs.x86_64 0:1.0.9-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 Repository Size ================================================================================ Installing: libcgroup x86_64 0.40.rc1-23.el6 base 131 k lxc x86_64 1.0.9-1.el6 epel 122 k Installing for dependencies: lua-alt-getopt noarch 0.7.0-1.el6 epel 6.9 k lua-filesystem x86_64 1.4.2-1.el6 epel 24 k lua-lxc x86_64 1.0.9-1.el6 epel 16 k lxc-libs x86_64 1.0.9-1.el6 epel 257 k Transaction Summary ================================================================================ Install 6 Package(s) Total download size: 557 k Installed size: 1.3 M Is this ok [y/N]: y Downloading Packages: (1/6): libcgroup-0.40.rc1-23.el6.x86_64.rpm | 131 kB 00:00 (2/6): lua-alt-getopt-0.7.0-1.el6.noarch.rpm | 6.9 kB 00:00 (3/6): lua-filesystem-1.4.2-1.el6.x86_64.rpm | 24 kB 00:00 (4/6): lua-lxc-1.0.9-1.el6.x86_64.rpm | 16 kB 00:00 (5/6): lxc-1.0.9-1.el6.x86_64.rpm | 122 kB 00:00 (6/6): lxc-libs-1.0.9-1.el6.x86_64.rpm | 257 kB 00:00 -------------------------------------------------------------------------------- Total 675 kB/s | 557 kB 00:00 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-6.el6_5.x86_64 has missing requires of libMySQLclient.so.16()(64bit) 2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit) 2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of mysql-libs Installing : lxc-libs-1.0.9-1.el6.x86_64 1/6 Installing : lua-filesystem-1.4.2-1.el6.x86_64 2/6 Installing : lua-lxc-1.0.9-1.el6.x86_64 3/6 Installing : lua-alt-getopt-0.7.0-1.el6.noarch 4/6 Installing : lxc-1.0.9-1.el6.x86_64 5/6 Installing : libcgroup-0.40.rc1-23.el6.x86_64 6/6 Verifying : lua-lxc-1.0.9-1.el6.x86_64 1/6 Verifying : lxc-libs-1.0.9-1.el6.x86_64 2/6 Verifying : lxc-1.0.9-1.el6.x86_64 3/6 Verifying : lua-alt-getopt-0.7.0-1.el6.noarch 4/6 Verifying : libcgroup-0.40.rc1-23.el6.x86_64 5/6 Verifying : lua-filesystem-1.4.2-1.el6.x86_64 6/6 Installed: libcgroup.x86_64 0:0.40.rc1-23.el6 lxc.x86_64 0:1.0.9-1.el6 Dependency Installed: lua-alt-getopt.noarch 0:0.7.0-1.el6 lua-filesystem.x86_64 0:1.4.2-1.el6 lua-lxc.x86_64 0:1.0.9-1.el6 lxc-libs.x86_64 0:1.0.9-1.el6 Complete! [root@iZwz9eczt2tstmhvm8mv25Z docker]#
4. 安装docker-io
yum install docker-io
[root@iZwz9eczt2tstmhvm8mv25Z docker]# yum install docker-io Loaded plugins: security Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package docker-io.x86_64 0:1.7.1-2.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: docker-io x86_64 1.7.1-2.el6 epel 4.6 M Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 4.6 M Installed size: 19 M Is this ok [y/N]: y Downloading Packages: docker-io-1.7.1-2.el6.x86_64.rpm | 4.6 MB 00:04 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : docker-io-1.7.1-2.el6.x86_64 1/1 Verifying : docker-io-1.7.1-2.el6.x86_64 1/1 Installed: docker-io.x86_64 0:1.7.1-2.el6 Complete! [root@iZwz9eczt2tstmhvm8mv25Z docker]#
5. 启动docker进程
/etc/init.d/docker start
[root@iZwz9eczt2tstmhvm8mv25Z docker]# /etc/init.d/docker start Starting cgconfig service: [ OK ] Starting docker: [确定] [root@iZwz9eczt2tstmhvm8mv25Z docker]#
6. 查看docker进程
ps -ef|grep docker
or /etc/init.d/docker status
卸载
yum remove docker-io
常见问题
启动不了
查看启动日志
docker -d
[root@iZwz9eczt2tstmhvm8mv25Z docker]# /etc/init.d/docker status docker 已死,但 pid 文件仍存 [root@iZwz9eczt2tstmhvm8mv25Z docker]# docker -d WARN[0000] You are running linux kernel version 2.6.32-573.22.1.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0. 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 [root@iZwz9eczt2tstmhvm8mv25Z docker]#
解决方式
安装:yum install device-mapper-event-libs
重启并查看其状态
[root@iZwz9eczt2tstmhvm8mv25Z docker]# /etc/init.d/docker restart 停止 docker: [失败] Starting docker: [确定] [root@iZwz9eczt2tstmhvm8mv25Z docker]# /etc/init.d/docker status docker (pid 17162) 正在运行... [root@iZwz9eczt2tstmhvm8mv25Z docker]#
关于“Docker如何安装与卸载”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
新闻名称:Docker如何安装与卸载
链接URL:http://myzitong.com/article/jcjgsg.html