Skip to content

Commit b39f854

Browse files
Copilotsunny0826
andcommitted
Restore Aliyun mirror and add enhanced logging for image checks
- Add back Aliyun (阿里云镜像加速) to image sources - Add detailed logging to checkImageExists for better debugging - Update documentation to reflect Aliyun support Co-authored-by: sunny0826 <24563928+sunny0826@users.noreply.github.com>
1 parent bbfd1b0 commit b39f854

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ KWDB Playground 是一个面向学习与演示的交互式课程平台,支持
4646

4747
支持灵活的镜像源选择,提高容器启动速度:
4848

49-
- **多镜像源支持**:Docker Hub、GitHub Container Registry (ghcr.io) 等镜像源
49+
- **多镜像源支持**:Docker Hub、GitHub Container Registry (ghcr.io)、阿里云等镜像源
5050
- **可用性检查**:启动前验证镜像源的可访问性和响应速度
5151
- **自定义源**:支持配置任意 Docker 镜像仓库地址
5252
- **配置持久化**:自动保存镜像源选择,下次访问时自动恢复

docs/usage-guide.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ KWDB Playground 支持灵活的 Docker 镜像源选择功能,允许用户根
244244
1. **预设镜像源**
245245
- Docker Hub(官方):默认镜像仓库
246246
- GitHub Container Registry (ghcr.io):GitHub容器镜像仓库
247+
- 阿里云镜像加速:`registry.cn-hangzhou.aliyuncs.com/`
247248
- 自定义源:支持输入任意镜像仓库地址
248249

249250
2. **镜像可用性检查**
@@ -298,6 +299,13 @@ GET /api/images/sources
298299
"prefix": "ghcr.io/",
299300
"description": "GitHub容器镜像仓库",
300301
"example": "ghcr.io/kwdb/kwdb:latest"
302+
},
303+
{
304+
"id": "aliyun",
305+
"name": "阿里云镜像加速",
306+
"prefix": "registry.cn-hangzhou.aliyuncs.com/",
307+
"description": "阿里云Docker镜像加速服务",
308+
"example": "registry.cn-hangzhou.aliyuncs.com/kwdb/kwdb:latest"
301309
}
302310
]
303311
}

internal/api/routes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,13 @@ func (h *Handler) getImageSources(c *gin.Context) {
15551555
"description": "GitHub容器镜像仓库",
15561556
"example": "ghcr.io/kwdb/kwdb:latest",
15571557
},
1558+
{
1559+
"id": "aliyun",
1560+
"name": "阿里云镜像加速",
1561+
"prefix": "registry.cn-hangzhou.aliyuncs.com/",
1562+
"description": "阿里云Docker镜像加速服务",
1563+
"example": "registry.cn-hangzhou.aliyuncs.com/kwdb/kwdb:latest",
1564+
},
15581565
{
15591566
"id": "custom",
15601567
"name": "自定义源",

internal/docker/controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,17 +1622,22 @@ func (d *dockerController) ensureImageExistsWithProgress(ctx context.Context, im
16221622

16231623
// checkImageExists 检查本地是否存在指定镜像
16241624
func (d *dockerController) checkImageExists(ctx context.Context, imageName string) (bool, error) {
1625+
d.logger.Debug("[checkImageExists] 检查镜像是否存在: %s", imageName)
1626+
16251627
// 使用 ImageInspect 检查镜像是否存在
16261628
_, _, err := d.client.ImageInspectWithRaw(ctx, imageName)
16271629
if err != nil {
16281630
// 如果是镜像不存在的错误,返回 false
16291631
if errdefs.IsNotFound(err) {
1632+
d.logger.Debug("[checkImageExists] 镜像不存在: %s", imageName)
16301633
return false, nil
16311634
}
16321635
// 其他错误使用详细的错误分类
16331636
errorMsg := d.classifyImageCheckError(err, imageName)
1637+
d.logger.Error("[checkImageExists] 检查镜像失败: %s, 错误: %s", imageName, errorMsg)
16341638
return false, fmt.Errorf(errorMsg)
16351639
}
1640+
d.logger.Debug("[checkImageExists] 镜像已存在: %s", imageName)
16361641
return true, nil
16371642
}
16381643

0 commit comments

Comments
 (0)