Ubuntu18安装docker

本文相关信息

  • 编写时间:2020-12-14
  • Ubuntu版本:V18.04
  • Docker版本:V19.03.14
  • Docker官方文档:传送门

卸载旧版本:(系统没有安装过docker,可以忽略)

$ sudo apt-get remove docker docker-engine docker.io containerd runc

一、设置仓库

  • 更新apt包:
$ sudo apt-get update
  • 让apt能通过HTTPS使用仓库:
$ sudo apt-get install \
  apt-transport-https \
  ca-certificates \
  curl \
  software-properties-common
  • 添加官方的GPG 密钥:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • 验证你的密钥:9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通过搜索指纹的后8个字符,验证是否拥有带有指纹的密钥。
$ sudo apt-key fingerprint 0EBFCD88  # 不用运行这行命令
  • 设置选用哪个版本:stable稳定版本
$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"

二、安装

  • 更新apt包:
$ sudo apt-get update
  • 开始安装:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

三、测试

$ sudo docker run hello-world
posted @ 2020-12-04 11:21  SonnyZhang  阅读(332)  评论(0编辑  收藏  举报