docker安装方法(常见安装出错问题汇总)
参考资料:
1. 开源中国 http://www.oschina.net/translate/nstalling-dockerio-on-centos-64-64-bit?cmp
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。
1 Docker与虚拟机
2 搭建过程
2.1 准备宿主系统
准备一个 CentOS 7操作系统,具体要求如下:
必须是 64 位操作系统
建议内核在 3.8 以上
通过以下命令查看您的 CentOS 内核:
1
|
# uname -r |
2.2 安装Docker
1
|
# yum install docker |
可使用以下命令,查看 Docker 是否安装成功:
1
|
# docker version |
若输出了 Docker 的版本号,则说明安装成功了,可通过以下命令启动 Docker 服务:
1
|
# systemctl start docker.service |
一旦 Docker 服务启动完毕,就可以开始使用 Docker 了。
yum安装时出现:Cannot retrieve metalink for repository: epel. Please verify its path and try again
在CentOS 6.3 x86_64下安装php-mcrypt的时候出现了问题:Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again,需要安装epel源。
解决方法: 一句话:把vi /etc/yum.repos.d/epel.repo,文件第3行注释去掉,把第四行注释掉。具体如下:将第六行的disabled改成为0 即disabled=1改成disabled=0
打开/etc/yum.repos.d/epel.repo,将
- [epel]
- name=Extra Packages for Enterprise Linux 6 - $basearch
- #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
- mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
修改为
- [epel]
- name=Extra Packages for Enterprise Linux 6 - $basearch
- baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
再清理源,重新安装
- yum clean all
- yum install -y 需要的包
如果还是不行,修改DNS,到/etc/resolv.conf下添加一下:
nameserver 8.8.8.8
search localdomain
然后重启network服务:service network restart
最近在群里听说Docker很火,于是自己抱着试试的态度,想玩玩,可是遇到了一些问题,记录下来,方便备忘,也方便防止大家被坑。
我的虚拟机装的是centos 6.5,百度了好多教程,丫的,都不解释,就一句命令:yum install docker-io,这句话是用源安装docker,可是源一般是国外源,用这个命令因为GFW被墙,根本安装不了。
- [root@localhost ~]# yum install docker-io
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.skyshe.cn
- * extras: mirrors.skyshe.cn
- * updates: centosx4.centos.org
- Setting up Install Process
- No package docker-io available.
- Error: Nothing to do
- <pre name="code" class="plain">[root@localhost ~]# yum install docker
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.163.com
- * extras: mirrors.skyshe.cn
- * updates: centosx4.centos.org
- Setting up Install Process
- No package docker available.
- Error: Nothing to do
总共尝试了好几次,所谓的镜像很不稳定,不是没有找到,就是找到了,下了一半就中途断了,哎,网上总是说一句话搞定,可是一句话搞定要有前提呀,于是乎,我看了开源中国的docker更新记录
-
Ubuntu/Debian: curl -sSL https://get.docker.com | sh
-
Linux 64bit binary: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1
-
Darwin/OSX 64bit client binary: https://get.docker.com/builds/Darwin/x86_64/docker-1.7.1
-
Darwin/OSX 32bit client binary: https://get.docker.com/builds/Darwin/i386/docker-1.7.1
-
Linux 64bit tgz: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1.tgz
-
Windows 64bit client binary: https://get.docker.com/builds/Windows/x86_64/docker-1.7.1.exe
-
Windows 32bit client binary: https://get.docker.com/builds/Windows/i386/docker-1.7.1.exe
-
Centos 6/RHEL 6: https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm
-
Centos 7/RHEL 7: https://get.docker.com/rpm/1.7.1/centos-7/RPMS/x86_64/docker-engine-1.7.1-1.el7.centos.x86_64.rpm
-
Fedora 20: https://get.docker.com/rpm/1.7.1/fedora-20/RPMS/x86_64/docker-engine-1.7.1-1.fc20.x86_64.rpm
-
Fedora 21: https://get.docker.com/rpm/1.7.1/fedora-21/RPMS/x86_64/docker-engine-1.7.1-1.fc21.x86_64.rpm
-
Fedora 22: https://get.docker.com/rpm/1.7.1/fedora-22/RPMS/x86_64/docker-engine-1.7.1-1.fc22.x86_64.rpm
啥也不说成功了,
- [root@localhost ~]# yum install https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.163.com
- * extras: mirrors.skyshe.cn
- * updates: centosx4.centos.org
- Setting up Install Process
- docker-engine-1.7.1-1.el6.x86_64.rpm | 4.5 MB 00:07
- Examining /var/tmp/yum-root-YSfgzS/docker-engine-1.7.1-1.el6.x86_64.rpm: docker-engine-1.7.1-1.el6.x86_64
- Marking /var/tmp/yum-root-YSfgzS/docker-engine-1.7.1-1.el6.x86_64.rpm to be installed
- Resolving Dependencies
- --> Running transaction check
- ---> Package docker-engine.x86_64 0:1.7.1-1.el6 will be installed
- --> Processing Dependency: libcgroup for package: docker-engine-1.7.1-1.el6.x86_64
- --> Running transaction check
- ---> Package libcgroup.x86_64 0:0.40.rc1-16.el6 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- ============================================================================================================================================================
- Package Arch Version Repository Size
- ============================================================================================================================================================
- Installing:
- docker-engine x86_64 1.7.1-1.el6 /docker-engine-1.7.1-1.el6.x86_64 19 M
- Installing for dependencies:
- libcgroup x86_64 0.40.rc1-16.el6 base 129 k
- Transaction Summary
- ============================================================================================================================================================
- Install 2 Package(s)
- Total size: 19 M
- Total download size: 129 k
- Installed size: 20 M
- Is this ok [y/N]: y
- Downloading Packages:
- libcgroup-0.40.rc1-16.el6.x86_64.rpm | 129 kB 00:00
- Running rpm_check_debug
- Running Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : libcgroup-0.40.rc1-16.el6.x86_64 1/2
- Installing : docker-engine-1.7.1-1.el6.x86_64 2/2
- Verifying : libcgroup-0.40.rc1-16.el6.x86_64 1/2
- Verifying : docker-engine-1.7.1-1.el6.x86_64 2/2
- Installed:
- docker-engine.x86_64 0:1.7.1-1.el6
- Dependency Installed:
- libcgroup.x86_64 0:0.40.rc1-16.el6
- Complete!
- [root@localhost ~]# service docker start
- Starting cgconfig service: [ OK ]
- Starting docker: [ OK ]
下面就开始玩玩docker了,以后慢慢分享
其他的大家可以看看:http://www.linuxidc.com/Linux/2014-07/104768.htm
https://linux.cn/article-4340-1.html
http://www.centoscn.com/image-text/config/2015/0718/5877.html