使用阿里云加速器
安装或升级Docker
curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -
安装完成,提示:
+ sh -c docker version
Client:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 21:44:32 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 21:44:32 2016
OS/Arch: linux/amd64
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker your-user
Remember that you will have to log out and back in for this to take effect!
查看docker版本
root@devstack-newton:~# docker -v
Docker version 1.12.3, build 6b644ec
如果主机是通过代理连接网络,执行docker search 操作时,会报如下错误
root@devstack-newton:~# docker search ubuntu
Error response from daemon: Get https://index.docker.io/v1/search?q=ubuntu&n=25: dial tcp: lookup index.docker.io on 10.33.176.66:53: read udp 11.11.175.55:46866->10.33.176.66:53: read: connection refused
解决方法是修改配置文件/etc/default/docker,设置代理
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
export http_proxy=http://ip:port
重启
service docker restart
再执行docker search ubuntu
root@devstack-newton:~# docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating s... 5178 [OK]
ubuntu-upstart Upstart is an event-based replacement for ... 69 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 56 [OK]
ubuntu-debootstrap debootstrap --variant=minbase --components... 27 [OK]
torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 27 [OK]
nickistre/ubuntu-lamp LAMP server on Ubuntu 13 [OK]
nuagebec/ubuntu Simple always updated Ubuntu docker images... 11 [OK]
nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu with wp-cli installed 8 [OK]
nimmis/ubuntu This is a docker images different LTS vers... 5 [OK]
maxexcloo/ubuntu Base image built on Ubuntu with init, Supe... 2 [OK]
admiringworm/ubuntu Base ubuntu images based on the official u... 1 [OK]
jordi/ubuntu Ubuntu Base Image 1 [OK]
darksheer/ubuntu Base Ubuntu Image -- Updated hourly 1 [OK]
vcatechnology/ubuntu A Ubuntu image that is updated daily 0 [OK]
datenbetrieb/ubuntu custom flavor of the official ubuntu base ... 0 [OK]
teamrock/ubuntu TeamRock's Ubuntu image configured with AW... 0 [OK]
labengine/ubuntu Images base ubuntu 0 [OK]
lynxtp/ubuntu https://github.com/lynxtp/docker-ubuntu 0 [OK]
webhippie/ubuntu Docker images for ubuntu 0 [OK]
widerplan/ubuntu Our basic Ubuntu images. 0 [OK]
esycat/ubuntu Ubuntu LTS 0 [OK]
smartentry/ubuntu ubuntu with smartentry 0 [OK]
ustclug/ubuntu ubuntu image for docker with USTC mirror 0 [OK]
konstruktoid/ubuntu Ubuntu base image 0 [OK]
uvatbc/ubuntu Ubuntu images with unprivileged user 0 [OK]
配置Docker加速器
使用如下的脚本将mirror的配置添加到docker daemon的启动参数中
如果您的系统是 Ubuntu 12.04 14.04,Docker 1.9 以上
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=https://ebrzfw28.mirror.aliyuncs.com\"" | sudo tee -a /etc/default/docker
如果您的系统是 Ubuntu 15.04 16.04,Docker 1.9 以上
mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/mirror.conf <<-'EOF' [Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// --registry-mirror=https://ebrzfw28.mirror.aliyuncs.com EOF
systemctl daemon-reload
systemctl restart docker
重启
service docker restart
拉取ubuntu14.04镜像
root@devstack-newton:~# docker pull ubuntu:14.04
14.04: Pulling from library/ubuntu
04cf3f0e25b6: Pull complete
d5b45e963ba0: Pull complete
a5c78fda4e14: Pull complete
193d4969ca79: Pull complete
d709551f9630: Pull complete
Digest: sha256:edb984703bd3e8981ff541a5b9297ca1b81fde6e6e8094d86e390a38ebc30b4d
Status: Downloaded newer image for ubuntu:14.04
由于使用了阿里的加速器,下载镜像非常快
查看镜像
root@devstack-newton:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 aae2b63c4946 12 days ago 188 MB