码迷,mamicode.com
首页 > 其他好文 > 详细

阿里云centos安装docker-engine实践

时间:2016-03-21 22:59:25      阅读:1021      评论:0      收藏:0      [点我收藏+]

标签:

近日在阿里云ECS服务器(centos系统)中安装docker,参考官方指南 https://docs.docker.com/engine/installation/linux/centos/  大概流程都能跑通,但是中途发生了一些意外情况,特记录备案以免后来再次踩坑。
 
一、需要有登录ECS的工具(推荐Xshell)和拥有root权限的用户。
 
二、确保linux内核版本是3.10以上并且是64位的centos版本。如果不能满足这个前提,建议看官绕道走吧。
 
     检查linux版本命令如下
$ uname -r
3.10.0-229.el7.x86_64

     以上前提条件都满足,接下来就开始安装。

 
三、升级yum安装包,确保都是最新的版本
 
 $  sudo yum update

 

四、在yum repository增加docker的repository
 
$  sudo vim /etc/yum.repos.d/docker.repo
 
## 在vim编辑器中输入以下内容后保存
 
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

 

五、到这一步都进展顺利,接下来开始通过yum安装docker-engine了。想不到的事情发生了。。。
 
 $  sudo yum install docker-engine

## yum开始从docker repository下载组件... 一切貌似进展顺利,然而突然出现一个错误 

warning: /var/cache/yum/x86_64/7/dockerrepo/packages/docker-engine-selinux-1.10.3-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
Retrieving key from https://yum.dockerproject.org/gpg
 
GPG key retrieval failed: [Errno 12] Timeout on https://yum.dockerproject.org/gpg: (28, ‘Resolving timed out after 3512 milliseconds‘)

怎么回事?从https://yum.dockerproject.org/repo/main/centos都能顺利下载其他组件,怎么就卡在https://yum.dockerproject.org/gpg这一步呢?

ping yum.dockerproject.org 显示一切网络正常。重试几次仍然同样故障。苦苦思索和尝试仍然没有结果,最后决定先绕道吧。(有知道的同学告知一声,不胜感激)
 
绕道的办法:
 
  1. 从本机中打开https://yum.dockerproject.org/gpg,下载PKI证书文件
 
  2. 在Xshell进行以下操作 
 
$  sudo vim /usr/local/docker.gpg 

## 在VIM编辑器中把本地下载的证书内容复制过去,保存

 
-----BEGIN PGP PUBLIC KEY BLOCK-----
 
mQINBFWln24BEADrBl5p99uKh8+rpvqJ48u4eTtjeXAWbslJotmC/CakbNSqOb9o
ddfzRvGVeJVERt/Q/mlvEqgnyTQy+e6oEYN2Y2kqXceUhXagThnqCoxcEJ3+KM4R
mYdoe/BJ/J/6rHOjq7Omk24z2qB3RU1uAv57iY5VGw5p45uZB4C4pNNsBJXoCvPn
TGAs/7IrekFZDDgVraPx/hdiwopQ8NltSfZCyu/jPpWFK28TR8yfVlzYFwibj5WK
dHM7ZTqlA1tHIG+agyPf3Rae0jPMsHR6q+arXVwMccyOi+ULU0z8mHUJ3iEMIrpT
X+80KaN/ZjibfsBOCjcfiJSB/acn4nxQQgNZigna32velafhQivsNREFeJpzENiG
HOoyC6qVeOgKrRiKxzymj0FIMLru/iFF5pSWcBQB7PYlt8J0G80lAcPr6VCiN+4c
NKv03SdvA69dCOj79PuO9IIvQsJXsSq96HB+TeEmmL+xSdpGtGdCJHHM1fDeCqkZ
hT+RtBGQL2SEdWjxbF43oQopocT8cHvyX6Zaltn0svoGs+wX3Z/H6/8P5anog43U
65c0A+64Jj00rNDr8j31izhtQMRo892kGeQAaaxg4Pz6HnS7hRC+cOMHUU4HA7iM
zHrouAdYeTZeZEQOA7SxtCME9ZnGwe2grxPXh/U/80WJGkzLFNcTKdv+rwARAQAB
tDdEb2NrZXIgUmVsZWFzZSBUb29sIChyZWxlYXNlZG9ja2VyKSA8ZG9ja2VyQGRv
Y2tlci5jb20+iQI4BBMBAgAiBQJVpZ9uAhsvBgsJCAcDAgYVCAIJCgsEFgIDAQIe
AQIXgAAKCRD3YiFXLFJgnbRfEAC9Uai7Rv20QIDlDogRzd+Vebg4ahyoUdj0CH+n
Ak40RIoq6G26u1e+sdgjpCa8jF6vrx+smpgd1HeJdmpahUX0XN3X9f9qU9oj9A4I
1WDalRWJh+tP5WNv2ySy6AwcP9QnjuBMRTnTK27pk1sEMg9oJHK5p+ts8hlSC4Sl
uyMKH5NMVy9c+A9yqq9NF6M6d6/ehKfBFFLG9BX+XLBATvf1ZemGVHQusCQebTGv
0C0V9yqtdPdRWVIEhHxyNHATaVYOafTj/EF0lDxLl6zDT6trRV5n9F1VCEh4Aal8
L5MxVPcIZVO7NHT2EkQgn8CvWjV3oKl2GopZF8V4XdJRl90U/WDv/6cmfI08GkzD
YBHhS8ULWRFwGKobsSTyIvnbk4NtKdnTGyTJCQ8+6i52s+C54PiNgfj2ieNn6oOR
7d+bNCcG1CdOYY+ZXVOcsjl73UYvtJrO0Rl/NpYERkZ5d/tzw4jZ6FCXgggA/Zxc
jk6Y1ZvIm8Mt8wLRFH9Nww+FVsCtaCXJLP8DlJLASMD9rl5QS9Ku3u7ZNrr5HWXP
HXITX660jglyshch6CWeiUATqjIAzkEQom/kEnOrvJAtkypRJ59vYQOedZ1sFVEL
MXg2UCkD/FwojfnVtjzYaTCeGwFQeqzHmM241iuOmBYPeyTY5veF49aBJA1gEJOQ
TvBR8Q==
=Fm3p
-----END PGP PUBLIC KEY BLOCK-----
$ sudo rpm --import /usr/local/docker.gpg

  3.手工导入docker的PKI公钥证书,安装总算能顺利进行下去了

 
 
六、安装docker-engine完成后,启动docker服务
 
 
$  sudo systemctl start docker.service

 

 
七、测试docker服务是否成功
 
 $  sudo docker run hello-world

##看到以下输出,就大功告成了 

Unable to find image hello-world:latest locally
latest: Pulling from library/hello-world
03f4658f8b78: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest
 
Hello from Docker.
This message shows that your installation appears to be working correctly.
 
To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.
 
To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash
 
Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com
 
For more examples and ideas, visit:
 https://docs.docker.com/userguide/
 

 

 

阿里云centos安装docker-engine实践

标签:

原文地址:http://www.cnblogs.com/andrew-xie/p/5304104.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!