Docker requires a 64-bit installation regardless of your Ubuntu version. Additionally, your kernel must be 3.10 at minimum. The latest 3.10 minor version or a newer maintained version are also acceptable.
上面什么意思?就是说docker在Ubuntu上的安装的架构必须是64位的,另外linux内核必须不能小于3.10。以上就是官方的要求啊,具体可以查看官方文档。
如果版本低了要升级。具体查看内核版本命令如下:
use uname -r to display your kernel version:
$ uname -r
3.11.0-15-generic
下面开始安装:
Update your apt sources Docker’s APT repository contains Docker 1.7.1 and higher. To set APT to use packages from the new repository:
1、Log into your machine as a user with sudo or root privileges.
2、Open a terminal window.
3、Update package information, ensure that APT works with the https method, and that CA certificates are installed.
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
4、Add the new GPG key.
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
5、用vi打开一个文件/etc/apt/sources.list.d/docker.list,如果没有这样的文件的话就创建它。这里涉及到权限的问题,如果是一个普通用户的话是没有写权限的,可以切换到超级用户,通过命令su root进行操作。
6、Remove any existing entries.
7、Add an entry for your Ubuntu operating system.
The possible entries are:
deb https://apt.dockerproject.org/repo ubuntu-xenial main
在那个docker.list文件中添加这句
8、Save and close the /etc/apt/sources.list.d/docker.list file.
Update the APT package index.
$ sudo apt-get update
9、Purge the old repo if it exists.
$ sudo apt-get purge lxc-docker
10、Verify that APT is pulling from the right repository.
$ apt-cache policy docker-engine
11、From now on when you run apt-get upgrade, APT pulls from the new repository.
$ apt-cache policy docker-engine
From now on when you run apt-get upgrade, APT pulls from the new repository.
12、Open a terminal on your Ubuntu host.Update your package manager.
$ sudo apt-get update
13、Install the recommended package.
$ sudo apt-get install linux-image-extra-$(uname -r)
14、Log into your Ubuntu installation as a user with sudo privileges.Update your APT package index.
$ sudo apt-get update
15、Install Docker.
$ sudo apt-get install docker-engine
16、Start the docker daemon.
$ sudo service docker start
17、Verify docker is installed correctly.
$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message. Then, it exits.
参考官方文档:https://docs.docker.com/engine/installation/linux/ubuntulinux/