Ubuntu22.04安装docker

1.卸载旧版本的docker

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

2.更新apt包索引

sudo apt-get update

3.安装apt依赖包

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

4.添加docker的GPG密钥

 curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

5.配置可用的镜像 重要

打开文件

sudo vim /etc/docker/daemon.json

 在文件中添加

{
  "registry-mirrors": [
    "https://docker.m.daocloud.io"
  ]
}


添加后先按esc退出insert,再按:wq保存并退出

6.安装docker

可能需要一段时间

sudo apt-get update

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

7.测试docker是否能正常工作

sudo docker run hello-world

若正常应该为

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                         Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest

8.随后可以查看docker版本

sudo docker version

查看镜像


sudo docker images

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值