docker安装踩坑指南(ubuntu 20.04 focal)

今天尝试安装docker,通过官网教程运行

$ sudo apt-get update

然后就报错了……

错误:5 https://download.docker.com/linux/ubuntu focal InRelease
  由于没有公钥,无法验证下列签名: NO_PUBKEY 7EA0A9C3F273FCD8

通过大量的尝试,发现需要自己添加公钥

#把提示的最后8位复制过来即可
$ sudo apt-key adv --recv-keys --keyserver keyserver.Ubuntu.com F273FCD8 

然后安装一系列的包

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

接着

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

这里又报错了……

curl: (77) error setting certificate verify locations:
  CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs

这个ca_certificates.crt文件有问题,从http://curl.haxx.se/ca/cacert.pem下载cacert.pem替换掉。

$ sudo cp /home/lif/桌面/cacert.pem /etc/ssl/certs/ca-certificates.crt

然后重新下载docker证书,成功,可以通过查看公钥来验证

$ sudo apt-key fingerprint 0EBFCD88

#如果提示如下 说明成功
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

接下来设置docker的库,我选的是stable版的

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

然后安装docker:

 $ sudo apt-get update
 $ sudo apt-get install docker-ce docker-ce-cli containerd.io

安装完成后,通过docker helloworld test 来测试是否安装成功!

$ sudo docker run hello-world

成功示例:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值