docker升级&加速器配置

默认使用yum或者apt安装的docker版本较老,可以通过以下方式进行升级:

1、卸载旧版本

[root@CentOS702 ~]# centos 7.3卸载docker
[root@CentOS702 ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@CentOS702 ~]# rpm -qa | grep docker docker-client-1.12.6-11.el7.centos.x86_64 docker-common-1.12.6-11.el7.centos.x86_64 docker-1.12.6-11.el7.centos.x86_64 [root@CentOS702 ~]# yum remove -y -q docker-client docker-common docker
[root@CentOS702 ~]# ubuntu 16.10卸载docker
liuyongsheng@ubuntu:~$ dpkg -l | grep docker
ii  docker.io                                  1.12.6-0ubuntu1~16.10.1                 amd64        Linux container runtime
liuyongsheng@ubuntu:~$ sudo apt-get --purge remove docker.io

2、安装最新版

[root@CentOS702 ~]# 可通过docker官方/阿里云/daocloud的安装脚本安装,适用于CentOS、Ubuntu、Debian等大部分linux系统
[root@CentOS702 ~]# curl -sSL https://get.docker.com/ | sh
[root@CentOS702 ~]# curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -
[root@CentOS702 ~]# curl -sSL https://get.daocloud.io/docker | sh
[root@CentOS702 ~]# systemctl start docker
[root@monitor ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@CentOS702 ~]# docker -v Docker version 17.03.0-ce, build 60ccb22 [root@CentOS702 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 0ef2e08ed3fa 3 weeks ago 130 MB hello-world latest 48b5124b2768 2 months ago 1.84 kB
[root@monitor ~]# CentOS系统也可配置官方源安装最新版,其它系统源地址参考:https://yum.dockerproject.org/repo/
[root@monitor ~]# uname -r 3.10.0-514.el7.x86_64 [root@monitor ~]# yum update -y -q [root@monitor ~]# tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg [root@monitor ~]# yum install -y docker-engine
[root@monitor ~]# systemctl start docker
[root@monitor ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@monitor ~]# docker -v Docker version 17.03.0-ce, build 60ccb22 [root@monitor ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world         latest              48b5124b2768        2 months ago        1.84 kB

3、配置阿里云加速器

[root@CentOS702 ~]# mkdir -p /etc/docker
[root@CentOS702 ~]# 配置/etc/docker/daemon.json方式适用于docker1.10以上版本,其它版本参考阿里云配置文档 [root@CentOS702 ~]# tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] } EOF { "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] } [root@CentOS702 ~]# systemctl daemon-reload [root@CentOS702 ~]# systemctl restart docker [root@CentOS702 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 0ef2e08ed3fa 3 weeks ago 130 MB hello-world latest 48b5124b2768 2 months ago 1.84 kB [root@CentOS702 ~]# docker pull centos Using default tag: latest latest: Pulling from library/centos 785fe1d06b2d: Pull complete Digest: sha256:be5b4a93f116a57ab3fd454ada72421eac892a3a4925627ac9a44f65fcd69cf8 Status: Downloaded newer image for centos:latest [root@CentOS702 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 98d35105a391 5 days ago 192 MB ubuntu latest 0ef2e08ed3fa 3 weeks ago 130 MB hello-world latest 48b5124b2768 2 months ago 1.84 kB

4、Docker Hub Mirror

阿里云:https://dev.aliyun.com/search.html  

DaoCloud:https://www.daocloud.io/mirror

5、参考网址

docker镜像源&加速器:

http://warjiang.github.io/devcat/2016/11/28/使用阿里云Docker镜像加速/

http://lx.wxqrcode.com/index.php/post/111.html

http://www.cnblogs.com/anliven/p/6218741.html

 

posted @ 2017-04-17 20:40  liuyongsheng  阅读(388)  评论(0编辑  收藏  举报