之前有一篇文章讲过在阿里云中安装Docker,相对来说那个是安装,但是安装完之后我们一般会碰到问题。
今天我给大家记录一下我的新的解决过程。
环境还是ubuntu12.04,假设我们已经把内核升级到了3.8以上。
便捷安装Docker命令:
curl -s https://get.docker.io/ubuntu/ | sudo sh
直接执行如下命令:
sudo docker run -i -t ubuntu /bin/bash
如下:
root@iZ28ikebrg6Z:~# docker run -i -t ubuntu /bin/bash 2014/10/15 21:19:19 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?好,我们的守候进程没有起来。
root@iZ28ikebrg6Z:~# docker -d出现如下错误:
root@iZ28ikebrg6Z:~# docker -d 2014/10/15 21:21:01 docker daemon: 1.2.0 fa7b24f; execdriver: native; graphdriver: [be668f49] +job serveapi(unix:///var/run/docker.sock) [info] Listening for HTTP on unix (/var/run/docker.sock) [be668f49] +job init_networkdriver() [be668f49.init_networkdriver()] creating new bridge for docker0 Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0' [be668f49] -job init_networkdriver() = ERR (1) 2014/10/15 21:21:01 Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
这个时候,很多人很困惑,搜索很多解决方法而不得解决,我也是,我试过很多方法,不过,我没记录下来,抱歉,现在我只知道正确的解决方法了
它来自http://segmentfault.com/q/1010000000438713
大家都在搜如何在阿里云里面部署Docker里面有一个人说:
改下路由表就可以了: sudo route del -net 172.16.0.0 netmask 255.240.0.0
root@iZ28ikebrg6Z:~# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 115.28.83.247 0.0.0.0 UG 0 0 0 eth1 10.0.0.0 10.163.191.247 255.0.0.0 UG 0 0 0 eth0 10.0.3.0 * 255.255.255.0 U 0 0 0 lxcbr0 10.163.176.0 * 255.255.240.0 U 0 0 0 eth0 115.28.80.0 * 255.255.252.0 U 0 0 0 eth1 172.16.0.0 10.163.191.247 255.240.0.0 UG 0 0 0 eth0 192.168.0.0 10.163.191.247 255.255.0.0 UG 0 0 0 eth0 root@iZ28ikebrg6Z:~# route del -net 172.16.0.0 netmask 255.240.0.0 root@iZ28ikebrg6Z:~# docker -d 2014/10/15 21:45:41 docker daemon: 1.2.0 fa7b24f; execdriver: native; graphdriver: [12f8faab] +job serveapi(unix:///var/run/docker.sock) [info] Listening for HTTP on unix (/var/run/docker.sock) [12f8faab] +job init_networkdriver() [12f8faab.init_networkdriver()] creating new bridge for docker0 [12f8faab.init_networkdriver()] getting iface addr [12f8faab] -job init_networkdriver() = OK (0) 2014/10/15 21:45:41 WARNING: Your kernel does not support cgroup swap limit. [info] Loading containers: [info] : done. [12f8faab] +job acceptconnections() [12f8faab] -job acceptconnections() = OK (0) [info] POST /images/create?fromImage=ubuntu&tag= [12f8faab] +job pull(ubuntu, )
至少没报错。好,守候进程算是起来了,不过,我们还是要验证一下能不能真正的用。
新开一个终端,输入:
root@iZ28ikebrg6Z:~# docker pull ubuntu Pulling repository ubuntu a9561eb1b190: Pulling dependent layers 3db9c44f4520: Downloading [====================> ] 26.42 MB/63.51 MB 14m3s c5881f11ded9: Pulling dependent layers 195eb90b5349: Pulling dependent layers 2185fd50e2ca: Pulling dependent layers 463ff6be4238: Pulling dependent layers 9cbaf023786c: Pulling dependent layers 511136ea3c5a: Download complete 6cfa4d1f33fb: Download complete
总结一下,最重要的呢,首先,记住上一篇文章中的内核,安装源什么的不要搞错。然后阿里云的特殊性,记得改路由表。
原文地址:http://blog.csdn.net/minimicall/article/details/40119177