╃苍狼山庄╃╃苍狼山庄╃

Clang出品,
必属精品!

Get Docker-CE for Debian or Raspbian

要在Debian上开始使用Docker-CE(Docker Community Edition),请确保您符合先决条件,然后安装Docker。

先决条件

系统要求:

要安装Docker,您需要64位版本的这些DebianRaspbian版本之一:

  • Stretch 9
  • Jessie 8.0 (LTS) / Raspbian Jessie
  • Wheezy 7.7 (LTS)
  • 额外要求:

    您至少需要版本3.10以上的Linux内核。 Debian Wheezy版本3.2版以上,所以您可能需要更新内核。
    检查你的内核版本:

    uname -r

    Install Docker

    如果你过去安装过 docker,先删掉:

    sudo apt-get remove docker docker-engine docker.io

    您可以根据需要以不同的方式安装Docker:

    大多数用户设置了Docker的存储库并从中安装,以方便安装和升级任务。 这是推荐的方法。
    一些用户下载DEB软件包并手动安装,并手动完成升级。
    有些用户不能使用官方的Docker存储库,并且必须依赖于其操作系统附带的Docker版本。 此版本的Docker可能已过期。 那些用户应该参考他们的操作系统文档,而不是按照这些步骤。

    使用repository进行安装:

    在新主机上首次安装Docker之前,需要设置Docker存储库。 之后,您可以从存储库安装,更新或降级Docker。

    设置repository

    1.Install packages to allow apt to use a repository over HTTPS:
    Jessie or newer:

    sudo apt-get install -y --no-install-recommends \
         apt-transport-https \
         ca-certificates \
         curl \
         gnupg2 \
         software-properties-common

    Wheezy or older:

    sudo apt-get install -y --no-install-recommends \
         apt-transport-https \
         ca-certificates \
         curl \
         python-software-properties

    2.Add Docker’s official GPG key:

    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

    Verify that the key ID is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

    apt-key fingerprint 0EBFCD88

    命令执行结果:

    pub   4096R/0EBFCD88 2017-02-22
          Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid                  Docker Release (CE deb) <docker@docker.com>
    sub   4096R/F273FCD8 2017-02-22

    3.Use the following command to set up the stable repository.
    Note: The lsb_release -cs sub-command below returns the name of your Debian distribution, such as jessie.
    Debian:

    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/debian \
       $(lsb_release -cs) \
       stable"
    sudo add-apt-repository \
       "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian \
       $(lsb_release -cs) \
       stable"
    sudo add-apt-repository \
       "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/debian \
       $(lsb_release -cs) \
       stable"
    sudo add-apt-repository \
       "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
       $(lsb_release -cs) \
       stable"

    Raspbian:

    echo "deb [arch=armhf] https://download.docker.com/linux/raspbian \
         $(lsb_release -cs) stable" | \
        sudo tee /etc/apt/sources.list.d/docker.list
    echo "deb [arch=armhf] https://mirrors.ustc.edu.cn/docker-ce/linux/raspbian \
         $(lsb_release -cs) stable" | \
        sudo tee /etc/apt/sources.list.d/docker.list
    echo "deb [arch= armhf] https://mirrors.aliyun.com/docker-ce/linux/raspbian \
         $(lsb_release -cs) stable" | \
        sudo tee /etc/apt/sources.list.d/docker.list
    echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/raspbian \
         $(lsb_release -cs) stable" | \
        sudo tee /etc/apt/sources.list.d/docker.list

    To enable the testing repository, you can edit /etc/apt/sources.list and add the word testing after main on the appropriate line of the file. Do not use unstable repositories on production systems or for non-testing workloads.

    安装Docker

    sudo apt-get update
    sudo apt-get -y install docker-ce

    Debian中docker是自动启动的,Raspbian中需要使用下面命令启动docker:

    sudo service docker start

    设置Docker镜像仓库

    在配置文件 /etc/docker/daemon.json 中加入:

    {
      "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
    }
    {
      "registry-mirrors": ["https://hub.c.163.com/"]
    }

    重新启动dockerd:

    sudo service docker restart

    Uninstall Docker

    1.Uninstall the Docker package:

    sudo apt-get purge docker-ce

    2.Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

    sudo rm -rf /var/lib/docker
    本原创文章未经允许不得转载 | 当前页面:╃苍狼山庄╃ » Get Docker-CE for Debian or Raspbian

    评论

    文章评论已关闭!