Page tree

如需转载请标注内容地址为: https://wiki.shileizcc.com/confluence/display/DOC/Docker+install

Skip to end of metadata
Go to start of metadata

官方文档:

Docker install

https://docs.docker.com/engine/installation/


最新版 Docker 安装

$ curl -fsSL https://get.docker.com/ | sh
# curl https://get.docker.com|sh -s -- --mirror Aliyun

Ubuntu

$ echo "deb \[arch=amd64\] https://apt.dockerproject.org/repo ubuntu-xenial main" > /etc/apt/sources.list.d/docker.list
$ apt update

Install a specific version

/etc/apt/sources.list.d/docker.list
deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main

To install a specific version of docker-engine:

  1. List all available versions using apt-cache madison:


    $ apt-cache madison docker-engine
    
    docker-engine | 17.04.0~ce-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 17.03.1~ce-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 17.03.0~ce-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.13.1-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.13.0-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.6-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.5-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.4-0~ubuntu-xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.3-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.2-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.1-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.12.0-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.11.2-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.11.1-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
    docker-engine | 1.11.0-0~xenial | https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
  2. The second field is the version string. To install exactly 1.12.0-0~xenial, append it after the package name in the apt-get install command, separated from the package name by an equals sign (=).bash

  3. $ sudo apt-get install docker-engine=1.12.6-0~ubuntu-xenial

如果上述方法找不到想要的版本可能因官方持续更新的 17.x 等版本会把之前的最新版本给替换掉,可以使用下面的源进行 1.12.x 版本的安装:

$ apt-get update && apt-get install -y apt-transport-https
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
$ apt-get update

查看版本:

$ apt-cache madison docker.io
 docker.io | 1.12.6-0ubuntu1~16.04.1 | http://asia-east1.gce.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
 docker.io | 1.10.3-0ubuntu6 | http://asia-east1.gce.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
 docker.io | 1.10.3-0ubuntu6 | http://asia-east1.gce.archive.ubuntu.com/ubuntu xenial/universe Sources
 docker.io | 1.12.6-0ubuntu1~16.04.1 | http://asia-east1.gce.archive.ubuntu.com/ubuntu xenial-updates/universe Sources

Centos

Centos 7 默认是 1.12.6 的源,不过需要安装 epel-release

$ yum install -y epel-release
$ yum install docker-ce

指定版本安装

配置源

$ cat > /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

更新缓存

$ yum makecache

安装

$ yum list|grep docker
docker-client.x86_64                    2:1.12.6-16.el7.centos         @extras
docker-common.x86_64                    2:1.12.6-16.el7.centos         @extras
cockpit-docker.x86_64                   135-4.el7.centos               extras
docker.x86_64                           2:1.12.6-16.el7.centos         extras
docker-client-latest.x86_64             1.13.1-4.el7.centos            extras
docker-devel.x86_64                     1.3.2-4.el7.centos             extras
docker-distribution.x86_64              2.6.0-1.el7                    extras
docker-engine.x86_64                    17.05.0.ce-1.el7.centos        dockerrepo
docker-engine-debuginfo.x86_64          17.05.0.ce-1.el7.centos        dockerrepo
docker-engine-selinux.noarch            17.05.0.ce-1.el7.centos        dockerrepo
docker-forward-journald.x86_64          1.10.3-44.el7.centos           extras
docker-latest.x86_64                    1.13.1-4.el7.centos            extras
docker-latest-logrotate.x86_64          1.13.1-4.el7.centos            extras
docker-latest-v1.10-migrator.x86_64     1.13.1-4.el7.centos            extras
docker-logrotate.x86_64                 2:1.12.6-16.el7.centos         extras
docker-lvm-plugin.x86_64                2:1.12.6-16.el7.centos         extras
docker-novolume-plugin.x86_64           2:1.12.6-16.el7.centos         extras
docker-python.x86_64                    1.4.0-115.el7                  extras
docker-registry.noarch                  0.6.8-8.el7                    extras
docker-registry.x86_64                  0.9.1-7.el7                    extras
docker-unit-test.x86_64                 2:1.12.6-16.el7.centos         extras
docker-v1.10-migrator.x86_64            2:1.12.6-16.el7.centos         extras
golang-github-fsouza-go-dockerclient-devel.x86_64
kdocker.x86_64                          4.9-1.el7                      epel
python-docker-py.noarch                 1.10.6-1.el7                   extras
python-docker-pycreds.noarch            1.10.6-1.el7                   extras
python-docker-scripts.noarch            0.4.4-1.el7                    epel
python-dockerfile-parse.noarch          0.0.5-1.el7                    epel
$ yum install docker-latest

或者:

$ yum list docker-ce --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
 
$ yum install docker-ce-18.09.0-3.el7


  • No labels