阿里云Ubuntu环境搭建Docker服务

经过昨天和今天的不断奋战,在阿里云里面搭建Docker并不easy。

所以我认为有必要记录下来,以供后人学习。

以及我自己的回想。

首先,查看我们的系统版本号

cat /etc/issue
的到的输出是
Ubuntu 12.04.1 LTS \n \l
我们顺便看一下内核版本号,由于Docker须要在3.8以上执行。
uname -r
能够得到你的内核版本号,我由于要装docker,所以依照docker官网的步骤升级了内核,所以输出是:
https://docs.docker.com/installation/ubuntulinux/
怎样升级内核?

升级内核的步骤事实上非常easy,依据Docker官网提供的就好:
指令例如以下:
# install the backported kernel
$ sudo apt-get update
$ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring

# install the backported kernel and xorg if using Unity/Xorg
$ sudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring

# reboot
$ sudo reboot

须要重新启动。

更新安装源
我在运行apt-get install docker.io的时候,总是提示找不到,所以说明我的安装源出了问题,所以,有必要说明怎样搞定安装源。让我们的过程无错进行。
首先,备份源列表
cp /etc/apt/sources.list /etc/apt/sources.list_backup
然后。用vim 打开 源列表文件。


vim /etc/apt/sources.list
清空里面的已有列表,然后,我们选择阿里云列表。由于我们是阿里云server嘛。


阿里云源列表例如以下:
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 update
这个时候会出现公钥问题


提示的错误类似例如以下:
W: There is no public key available for the following key IDs:
8B48AD6246925553
于是,我们又得解决问题。


运行例如以下命令:
apt-get install debian-keyring debian-archive-keyring && sudo apt-key update
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 8B48AD6246925553

上述命令,的那个数字要换成你的,亲。

然后,再次运行apt-get update。
发现能够了。没有问题。
于是,我们又回到“正事”,安装docker
apt-get install docker.io

这次顺利的完毕了安装。

开启服务
root@iZ28ikebrg6Z:/etc/apt# service docker.io restart
stop: Unknown instance: 
docker.io start/running, process 11430


只是接下来还会碰到问题。

 docker run -i -t ubuntu /bin/bash
2014/10/15 11:31:30 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?


这个问题。下节继续。