ubuntu18.04 安装docker

服务器是腾讯云的低配,已经吃灰好久,只放了公交的api,最近还被黑了,重装了系统,放着也是放着,打算拿来学习docker。

1.更新系统软件

sudo apt-get update

2.安装依赖包

sudo apt-get install \
    apt-transport-https \
 ca-certificates \
    curl \
 gnupg-agent \
    software-properties-common

3.下载并安装秘钥,任选其一就行

# 官方源
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


# 中科大源
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -


# 清华源
$ curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -


# 检查秘钥是否安装成功
$ sudo apt-key fingerprint 0EBFCD88

4.添加安装docker的软件源,如果觉得官方源慢的,可以选择中科大源和清华源

之前我没有设置源,导致安装失败,这里可以选择中科大源或者清华源

# 中科大源
$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
     
# 清华源
$ sudo add-apt-repository \
  "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
  $(lsb_release -cs) \
  stable"

5.安装docker-ce

sudo apt install docker-ce

32a221d8a94058e23549039a3c5d91c0.png

到这,就安装完成了。

posted @ 2022-05-31 18:10  青年码农  阅读(908)  评论(0编辑  收藏  举报