手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2014年08月18日的文章

怎样在阿里云上安装docker

因为debian 7安装docker的手续比较麻烦,所以我把阿里云的系统换成了ubuntu 14.04,然后参考:https://docs.docker.com/installation/ubuntulinux/

还算比较方便:apt-get update && apt-get install docker.io,然后再改两个配置就完事了。

不过,在你运行docker run -i -t ubuntu /bin/bash的时候,会报错,说是docker -d好象没有运行,这不科学 啊,刚刚不是装好的吗?

于是ps aux|grep docker,果然没有进程,于是直接输入:docker -d,然后就发现报错了:

XML/HTML代码
  1. 2014/08/18 12:05:42 Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'  

老规矩,内事不决问度娘,外事不决问谷歌,结果居然看到有人回复 :

大小: 46.71 K
尺寸: 500 x 174
浏览: 1772 次
点击打开新窗口浏览全图

当时这个心就碎了,心想这不科学啊,于是再google,就真的发现了:

大小: 65.11 K
尺寸: 500 x 235
浏览: 1843 次
点击打开新窗口浏览全图

OK,那就试试吧:

XML/HTML代码
  1. sudo brctl addbr docker0 # create your bridge  
  2. sudo brctl addif docker0 eth0 # mask an existing interface using the bridge  
  3. sudo ip link set dev docker0 up # bring it up - not really sure if this is necessary or is it done automatically  
  4. sudo ifconfig docker0 10.0.0.4 # give it an IP  

当然要运行brctl还是要装一个bridge-utils工具的,当然这个ubuntu会提醒你,一步步的做完后,docker 果然可以启动了。这时候再运行一下,service docker.io start,然后ps aux|grep docker,进程还活着。

于是输入:

XML/HTML代码
  1. docker run -i -t ubuntu /bin/bash  
  2. Unable to find image 'ubuntu' locally  
  3. Pulling repository ubuntu  
  4. 2014/08/18 12:16:44 Get https://index.docker.io/v1/repositories/ubuntu/images: dial tcp: lookup index.docker.io on 10.143.22.118:53: no answer from server  

咦。不能上网。其实就是上面的代码的问题,因为默认aliyun的eth0是内网IP,所以上述的

  1. sudo brctl addif docker0 eth0 # mask an existing interface using the bridge  
  2. 这里应该用eth1

重新执行一下。然后再次运行:

XML/HTML代码
  1. docker run -i -t ubuntu /bin/bash  
  2. Unable to find image 'ubuntu' locally  
  3. Pulling repository ubuntu  
  4. c5881f11ded9: Download complete   
  5. 。。。。。。。  

整个就完成了

 

Tags: docker, aliyun