ubuntu 20.04 安装docker--小白学习之路

更新包

sudo apt-get update

安装需要的软件包以使apt能够通过HTTPS使用仓库 sudo apt-get install ca-certificates curl gnupg lsb-release

使用清华大学源

添加Docker官方的GPG密钥

curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

设置稳定版仓库

echo "deb arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

使用阿里云源

添加阿里云官方GPG密钥

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - # 写入阿里云Docker仓库地址

sudo sh -c 'echo "deb arch=amd64 http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list'

更新源并安装Docker

sudo apt-get update

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

验证是否成功安装了

docker sudo systemctl status docker

docker --version

修改docker的/etc/docker/daemon.json配置文件,如果在不存在则手动创建,文件内容如下。

修改daemon.json文件,

vim /etc/docker/daemon.json

daemon.json内容如下:

{ "registry-mirrors": "https://dockerproxy.com", "https://docker.m.daocloud.io", "https://cr.console.aliyun.com", "https://ccr.ccs.tencentyun.com", "https://hub-mirror.c.163.com", "https://mirror.baidubce.com", "https://docker.nju.edu.cn", "https://docker.mirrors.sjtug.sjtu.edu.cn", "https://github.com/ustclug/mirrorrequest", "https://registry.docker-cn.com" }

重载配置文件,并重启

docker sudo systemctl daemon-reload

sudo systemctl restart docker

查看 Registry Mirrors 配置是否成功

sudo docker info

参考链接:ubuntu 20.04 国内源安装docker - lqqgis - 博客园

相关推荐
Wellijohn15 小时前
Docker 瘦身、手写 MCP、异步并发:被问得最多的 12 个问题,一次答完
python·docker·mcp
隔窗听雨眠16 小时前
KWDB容器化部署的形态选择与参数细节
docker·时序数据库·kwdb
SeanQhl20 小时前
openEuler 下 Docker 镜像操作与多阶段构建瘦身
docker·容器·镜像·openeuler·dockerfile
新*1 天前
ES 7.17 三节点 Docker 集群的自动备份:从 NFS 被拦住到用 ACL 根治权限
运维·elasticsearch·docker·slm·快照备份
木子欢儿1 天前
Ubuntu 26.04 LTS 安装Python 3.12
linux·运维·服务器·python·ubuntu
Wellijohn1 天前
Docker 镜像从 1.2GB 压到 180MB:按这个顺序改,别一上来就 multistage
docker
叼烟扛炮1 天前
[LangChain] 学习笔记(24):流式不改总耗时,只改「多久看到第一个字」——实测差 3 倍
笔记·学习·langchain
AR-26710-1 天前
docker Day4——命令小结与实操作业
运维·docker·容器
AR-26710-2 天前
docker Day3——镜像,容器,日志与元数据
运维·docker·容器
半扇排骨2 天前
特别篇:在线 XSS 靶场 haozi 分享与通关笔记
学习·安全·靶场·xss