uname -r 4.4.0-57-generic
1.更新apt资源
- 普通用户登录时命令需使用sudo,root用户可直接执行
- 直接在ubuntu主机上打开一个终端,或者在Windows机器上用xshell登录
- 执行如下命令
$ sudo apt-get update $ sudo apt-get install apt-transport-https ca-certificates
2.执行如下命令 追加一个新的GPG key
$ sudo apt-key adv \ --keyserver hkp://ha.pool.sks-keyservers.net:80 \ --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
3.执行命令
$ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
4.更新APT package index
$ sudo apt-get update
5.验证APT是否从正确的仓库拉取数据
apt-cache policy docker-engine
docker-engine: 已安装:1.12.5-0~ubuntu-xenial 候选: 1.12.5-0~ubuntu-xenial 版本列表: *** 1.12.5-0~ubuntu-xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 100 /var/lib/dpkg/status 1.12.4-0~ubuntu-xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.12.3-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.12.2-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.12.1-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.12.0-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.11.2-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.11.1-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages 1.11.0-0~xenial 500 500 https://get.daocloud.io/docker/apt-repo ubuntu-xenial/main amd64 Packages
6.安装 linux-image-extra-*核心包,保证能够使用aufs 存储驱动
$ sudo apt-get update $ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
7.安装docker
$ sudo apt-get install docker-engine
Docker 的 安装资源文件 存放在Amazon S3,国内访问不稳定,下载速度也特别慢,可以你可以通过执行下面的命令,高速安装Docker
curl -sSL https://get.daocloud.io/docker | sh
8.启动docker
$ sudo service docker start
9.验证docker是否安装成功
$ sudo docker run hello-world
Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
其他配置
1.如果不是root用户登录,执行docker命令时都要追加sudo,比较不方便,下面配置下普通用户不使用sudo执行docker命令
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ docker run hello-world
2.配置docker images加速器(利用DaoCloud)
{"registry-mirrors": ["http://XXXXXXX.m.daocloud.io"]}
将 XXXXXXX 替换成自己在DaoCloud的id。
配置完成后再下载镜像能感觉到速度的明显提升