最近大家都在说Docker,索性自己阿里云买了台Ubuntu服务器,这里需要注意的是,docker的官方文档中有提到,docker目前只对64的系统有支持。
所以这里我选择的是ubuntu 12.04 64位.
由于Linux容器的bug,docker在Linux的kernel3.8上运行最佳。
看下我们的Ubuntu版本命令:
root@linuxidc:~# cat /etc/issueUbuntu 12.04.5 LTS \n \l
再来看下内核,命令:
root@linuxidc:~# uname -r3.2.0-67-generic
很不幸我的内核版本没有达到官方要求,没关系,我们接下来用下面的命令升级内核:
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raringsudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring
注意:升级后需要重启ubuntu.#重启
sudo reboot
现在我们的环境都准备好,接下来我们要正式的安装部署docker.
首先我们要更新apt-get的安装源
root@linuxidc:~# vi /etc/apt/sources.list
删除里面的所有内容,把下面的安装源写入
deb trusty main restricted universe multiverse
deb trusty-security main restricted universe multiverse
deb trusty-updates main restricted universe multiverse
deb trusty-proposed main restricted universe multiverse
deb trusty-backports main restricted universe multiverse
deb-src trusty main restricted universe multiverse
deb-src trusty-security main restricted universe multiverse
deb-src trusty-updates main restricted universe multiverse
deb-src trusty-proposed main restricted universe multiverse
deb-src trusty-backports main restricted universe multiverse
然后更新apt-get
root@linuxidc:~#apt-get update
root@linuxidc:~#apt-get install docker.io
root@linuxidc:~# service docker.io restart
接下来我们启动docker
root@linuxidc:~#docker run -i -t ubuntu /bin/bash
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
root@linuxidc:~#docker run -i -t ubuntu /bin/bash
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
root@iZ28ikebrg6Z:~# docker -d
出现如下错误:
root@iZ28ikebrg6Z:~# docker -d
Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
然后我们只需要输入:
root@linuxidc:~#sudo route del -net 172.16.0.0 netmask 255.240.0.0
注意这里,每次重启后都要执行上面这条命令,制定子网掩码。
root@linuxidc:~# 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,到这里我们的安装算是完成了。
CentOS 6/7系列安装Docker