Docker的安装过程受操作系统和内核版本影响较大。这篇文章针对Ubuntu14.04,内核3.13.0以上版本进行说明。
如果采用的是其他Ubuntu发布版本请参考https://docs.docker.com/engine/installation/linux/ubuntulinux/
1、更新APT源
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
2、设置GPG密钥
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
3、根据发布版本设置仓库地址
Ubuntu version Repository
Precise 12.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-precise main
Trusty 14.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-trusty main
Wily 15.10 deb https://apt.dockerproject.org/repo ubuntu-wily main
Xenial 16.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-xenial main
$ echo "<REPO>" | sudo tee /etc/apt/sources.list.d/docker.list
由于是Ubuntu14.04所以执行
$ echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
4、检测APT可以从正确的仓库中下载
$ apt-cache policy docker-engine
docker-engine:
Installed: 1.12.2-0~trusty
Candidate: 1.12.2-0~trusty
Version table:
*** 1.12.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
100 /var/lib/dpkg/status
1.12.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.12.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.11.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.11.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
5、更新源并安装推荐包
$ sudo apt-get update
$ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
6、更新源、安装、启动
$ sudo apt-get update
$ sudo apt-get install docker-engine
$ sudo service docker start
7、检测是否安装正确
$ sudo docker info
Containers: 4
Running: 0
Paused: 0
Stopped: 4
Images: 3
Server Version: 1.12.3
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 19
Dirperm1 Supported: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor
Kernel Version: 3.13.0-39-generic
Operating System: Ubuntu 14.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 48
Total Memory: 125.5 GiB
Name: huawei06
ID: IAUC:3ACF:SAHK:UM6U:MFIN:USJX:5CDU:P6LR:U57G:BUDY:P42A:OV7H
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
127.0.0.0/8