环境说明

本案例中使用的是Ubuntu20.04LTS

本示例中docker使用发文时的最新版本,全部使用默认配置,如需自定义配置,请参考官方文档

安装配置步骤

Docker

  1. 首先确保卸载所有的老版本docker

    sudo apt-get remove docker docker-engine docker.io containerd runc
  2. 更新apt源,安装仓库

    sudo apt-get update

    sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg
  3. 增加Docker的官方GPG key

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  4. 安装docker仓库

    • X86/amd64安装命令

      echo \
      "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    • armhf安装命令

      echo \
      "deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    • arm64安装命令

      echo \
      "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullces.list.d/docker.list > /dev/null
  5. 安装docker引擎(使用默认版本)

    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io
  6. 验证docker安装

    sudo docker run hello-world