Skip to content

Commit 30f3aa6

Browse files
authored
Merge pull request #100 from mdhb0546/main
处理docker公开仓库也需要鉴权的问题
2 parents a062adf + a69bee4 commit 30f3aa6

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

.github/workflows/image-mirror.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ jobs:
7878
if: steps.check_body.outputs.is_image_format == 'true'
7979
id: syncImage
8080
env:
81+
DOCKERHUB_USER: ${{ vars.DOCKERHUB_USER }}
82+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
8183
TARGET_REGISTRY_PASSWORD: ${{ secrets.TARGET_REGISTRY_PASSWORD }}
8284
TARGET_REGISTRY_USER: ${{ vars.TARGET_REGISTRY_USER }}
8385
# TARGET_REGISTRY: index.docker.io

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@
2323
![image](https://github.com/imdingtalk/image-mirror/assets/16778873/a83b8765-3bd1-4391-afb3-cd8d4bc4718d)
2424
![image](https://github.com/imdingtalk/image-mirror/assets/16778873/b4623fca-43c2-4f55-bfb1-cef2e949fb93)
2525
比如我们要同步一个外部镜像到`registry.cn-hangzhou.aliyuncs.com/imdingtalk/kube-apiserver:v1.27.12`
26-
需要设置一些变量
2726

28-
- **TARGET_NAMESPACE:** 目标`NAMESPACE`,该例子中应该设置为`imdingtalk`
29-
- **TARGET_REGISTRY:** 目标仓库,该例子中应该设置为`registry.cn-hangzhou.aliyuncs.com`
30-
- **TARGET_REGISTRY_USER:** 目标仓库的用户名
31-
- **TARGET_REGISTRY_PASSWORD:** 目标仓库的密码
27+
需要设置一些变量 `variables`
28+
- **DOCKERHUB_USER:** 如果源仓库是dockerhub,即使公开仓库,也是需要鉴权信息,填写`dockehub`用户名
29+
- **TARGET_NAMESPACE:** 目标`NAMESPACE`,该例子中应该设置为`imdingtalk`
30+
- **TARGET_REGISTRY:** 目标仓库,该例子中应该设置为`registry.cn-hangzhou.aliyuncs.com`
31+
- **TARGET_REGISTRY_USER:** 目标仓库的用户名
32+
一些`secrets`
33+
- **DOCKERHUB_PASSWORD:** 如果源仓库是dockerhub,即使公开仓库,也是需要鉴权信息,填写`dockehub`密码
34+
- **TARGET_REGISTRY_PASSWORD:** 目标仓库的密码
35+
3236
该例子中,需要确保使用目标仓库的用户名和密码,使用命令 `docker login registry.cn-hangzhou.aliyuncs.com`能够成功登录
3337
4. 按照直接使用的方式在自己的仓库提交issue
3438

auth.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
index.docker.io:
2-
username: $TARGET_REGISTRY_USER
3-
password: $TARGET_REGISTRY_PASSWORD
2+
username: $DOCKERHUB_USER
3+
password: $DOCKERHUB_PASSWORD
4+
docker.io:
5+
username: $DOCKERHUB_USER
6+
password: $DOCKERHUB_PASSWORD
47
registry-1.docker.io:
5-
username: $TARGET_REGISTRY_USER
6-
password: $TARGET_REGISTRY_PASSWORD
8+
username: $DOCKERHUB_USER
9+
password: $DOCKERHUB_PASSWORD
710
registry.hub.docker.com:
8-
username: $TARGET_REGISTRY_USER
9-
password: $TARGET_REGISTRY_PASSWORD
10-
docker.io:
11-
username: $TARGET_REGISTRY_USER
12-
password: $TARGET_REGISTRY_PASSWORD
11+
username: $DOCKERHUB_USER
12+
password: $DOCKERHUB_PASSWORD
1313
registry.cn-hangzhou.aliyuncs.com:
1414
username: $TARGET_REGISTRY_USER
1515
password: $TARGET_REGISTRY_PASSWORD

0 commit comments

Comments
 (0)