可以通过在 config.toml
文件中设置 [[runners.docker]]
的 registry_mirror
参数来指定 Docker 注册中心。
具体步骤如下:
- 打开
config.toml
文件,找到并编辑以下行:
[[runners]]
executor = "docker"
[runners.docker]
# ...
registry_mirror = "https://your.registry.mirror"
将
https://your.registry.mirror
替换为你的 Docker 注册中心地址。保存文件并重新启动 GitLab Runner。
注意事项:
- 如果需要使用私有仓库,还需添加 Docker Hub 账号信息,例如:
[[runners]]
executor = "docker"
[runners.docker]
image = "ubuntu:latest"
privileged = true
disable_cache = false
volumes = ["/cache"]
pull_policy = "if-not-present"
registry_mirror = "https://your.registry.mirror"
username = "your_dockerhub_username"
password = "your_dockerhub_password"
- 如果你的 Docker 注册中心要求认证,那么还需设置
[[runners.docker]]
的tls_verify
、tls_cert_path
和tls_key_path
参数,以及[[runners.docker]]
下的image
参数。
总的来说,可以根据实际情况调整配置参数。