惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
A
About on SuperTechFans
U
Unit 42
MyScale Blog
MyScale Blog
J
Java Code Geeks
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
D
Docker
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
量子位
月光博客
月光博客
G
Google Developers Blog
V
V2EX
博客园 - 聂微东
宝玉的分享
宝玉的分享
IT之家
IT之家
Vercel News
Vercel News

博客园 - TanSea

VMware虚拟机下Linux系统(Ubuntu桌面版)微服务环境搭建 - 构建篇 VMware虚拟机下Linux系统(Ubuntu桌面版)微服务环境搭建 - Gogs篇 VMware虚拟机下Linux系统(Ubuntu桌面版)微服务环境搭建 - Jenkins篇 VMware虚拟机下Linux系统(Ubuntu桌面版)微服务环境搭建 - 准备篇 Sql Server 分批复制数据 Sql Server 查询数据库表结构 MAUI Blazor+MASA开发安卓应用学习笔记 - 设置图标和初始屏幕 MAUI Blazor+MASA开发安卓应用学习笔记 - 设置APP格式、名称、版本信息 MAUI Blazor+MASA开发安卓应用学习笔记 - 新建项目和发布 一道SQL面试题的解题思路 Windows10设置默认简体美式键盘输入法 C# 历史版本特性变更(更新到C# 11) SQL Server Report Builder RDLC按记录数分页 一次Exchange邮箱接口的开发经历 SQL Server分页查询进化史 一次.NET项目反编译的实战经验(WinForm) 点石成金-访客至上的网站设计秘笈 读书笔记 Windows7使用无线网卡建立WiFi热点 程序员的职业素养 读书笔记 - 第14章 辅导、学徒期与技艺
VMware虚拟机下Linux系统(Ubuntu桌面版)微服务环境搭建 - Doc...
TanSea · 2025-08-28 · via 博客园 - TanSea

安装依赖

sudo apt update
sudo apt install curl -y

添加 Docker 官方 GPG 公钥

1.创建密钥环目录

sudo install -m 0755 -d /etc/apt/keyrings
参数说明:
-m:设置模式,即设置文件或目录的权限
0755:一个八进制的权限掩码
    第一位0:表示特殊权限位,这里为 0 表示没有特殊权限
    第二位7:表示所有者的权限,74 (读) + 2 (写) + 1 (执行) 的和,所以所有者有读、写、执行权限
    第三位5:表示所属组的权限。54 (读) + 1 (执行) 的和,所以组有读和执行权限。
    第四位5:表示其他用户的权限。同样,有读和执行权限
-d:创建目录

2.下载并保存 GPG 公钥

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
参数说明:
-f:失败时静默退出 -s:静默模式 -S:当处于静默模式时显示错误 -L:跟随重定向,curl 会自动跟随重定向,并获取最终目标 URL 的内容

3.设置权限

sudo chmod a+r /etc/apt/keyrings/docker.gpg

安装 Docker

1.添加 APT 源

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
  $(. /etc/os-release && echo $VERSION_CODENAME) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
参数说明:
arch:指定此源适用于的系统架构 $(...):命令替换,Shell 会先执行括号内的命令,并将其输出结果插入到原位置 dpkg
--print-architecture:输出当前系统的架构 signed-by:指定用于验证的 GPG 公钥文件的路径 . /etc/os-release && echo $VERSION_CODENAME:获取系统的发行版代号,比如我系统就是Ubuntu24.04 => Noble

2.更新 APT 缓存

3.安装 Docker CE

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

验证 Docker 是否运行

sudo systemctl status docker

 如果看到active (running) 表示 Docker 守护进程已启动

4.添加权限

 将 tansea 用户加入 docker 组(可以免密使用Docker)

sudo usermod -aG docker tansea
# 重新登录使变更生效
su - tansea
参数说明:
-aG:将用户添加到 docker 用户组中,并且不改变用户当前所属的任何其他组

验证是否可以免 sudo 运行 Docker

看到有Client和Server的信息就表示生效了

5.配置国内镜像加速

自己找的一些国内镜像网站,如果失效了自行搜索

sudo tee /etc/docker/daemon.json << 'EOF'
{
  "registry-mirrors": [
    "https://2a6bf1988cb6428c877f723ec7530dbc.mirror.swr.myhuaweicloud.com",
    "https://docker-0.unsee.tech",
    "https://docker-registry.nmqu.com",
    "https://docker.1ms.run",
    "https://docker.apiba.cn",
    "https://docker.cattt.net",
    "https://docker.etcd.fun",
    "https://dockerpull.pw",
    "https://hub.amingg.com",
    "https://hub.mirrorify.net",
    "https://image.cloudlayer.icu",
    "https://proxy.vvvv.ee"
  ],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

重启 Docker 生效配置

sudo systemctl daemon-reload
sudo systemctl restart docker

测试拉取镜像

应该看到

Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:...
Status: Downloaded newer image for hello-world:latest

可以再测试一个