最近大家都在说docker,索性自己阿里云买了台ubuntu完,这里需要注意的是,docker的官方文档中有提到,docker目前只对64的系统有支持。
所以这里我选择的是ubuntu 12.04 64位.
由于linux容器的bug,docker在linux的kernel3.8上运行最佳。
看下我们的ubuntu版本命令:
[email protected]:~# cat /etc/issue
Ubuntu 12.04.5 LTS \n \l
再来看下内核,命令:
[email protected]:~# uname -r
3.2.0-67-generic
很不幸我的内核版本没有达到官方要求,没关系,我们接下来用下面的命令升级内核:
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring
注意:升级后需要重启ubuntu.#重启 sudo reboot
现在我们的环境都准备好,接下来我们要正式的安装部署docker.
首先我们要更新apt-get的安装源
[email protected]:~# vi /etc/apt/sources.list
删除里面的所有内容,把下面的安装源写入
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
然后更新apt-get
[email protected]:~#apt-get update
[email protected]:~#apt-get install docker.io
[email protected]:~# service docker.io restart
接下来我们启动docker
[email protected]:~#docker run -i -t ubuntu /bin/bash
Cannot connect to the Docker daemon. Is ‘docker -d‘ running on this host?
[email protected]:~#docker run -i -t ubuntu /bin/bash
Cannot connect to the Docker daemon. Is ‘docker -d‘ running on this host?
[email protected]:~# docker -d
出现如下错误:
[email protected]:~# docker -d
Could not find a free IP address range for interface ‘docker0‘. Please configure its address manually and run ‘docker -b docker0‘
然后我们只需要输入:
[email protected]:~#sudo route del -net 172.16.0.0 netmask 255.240.0.0
注意这里,每次重启后都要执行上面这条命令,制定子网掩码。
[email protected]:~# docker -d
2015/04/10 15:09:43 docker daemon: 1.0.1 990021a; execdriver: native; graphdriver:
[377a9034] +job serveapi(unix:///var/run/docker.sock)
[377a9034] +job initserver()
[377a9034.initserver()] Creating server
2015/04/10 15:09:43 Listening for HTTP on unix (/var/run/docker.sock)
[377a9034] +job init_networkdriver()
[377a9034.init_networkdriver()] creating new bridge for docker0
[377a9034.init_networkdriver()] getting iface addr
[377a9034] -job init_networkdriver() = OK (0)
Loading containers: : done.
[377a9034.initserver()] Creating pidfile
[377a9034.initserver()] Setting up signal traps
[377a9034] -job initserver() = OK (0)
[377a9034] +job acceptconnections()
[377a9034] -job acceptconnections() = OK (0)
ok,到这里我们的安装算是完成了。