参考此 youtube 教程来构建 docker 镜像并使用 Jenkins 将其推送到 docker hub
https://www.youtube.com/watch?v=z32yzy4TrKM
基本上它从 github (https://github.com/miltonchandradas/dockerwebapp) 进行轮询并运行其中的 jenkinsfile。
除了最后一步将图像推送到 docker hub 之外,一切对我来说都工作正常。
Jenkinsfile 就是这样的
node {
checkout scm
docker.withRegistry('https://registry.hub.docker.com', 'dockerHub') {
def customImage = docker.build("miltonc/dockerwebapp")
/* Push the container to the custom Registry */
customImage.push()
}
}
我使用相同的 Jenkinsfile,并且已经创建了自己的名为 dockerHub 的 docker hub 凭证,但仍然出现以下错误
denied: requested access to the resource is denied
我想知道我是否不应该构建名为 miltonc/dockerwebapp 的图像来复制作者的原始图像?
知道我应该如何改变它吗?
这是因为
https://registry.hub.docker.com
是使用的旧参考。
使用
registry.docker.io
或 registry-1.docker.io
代替 registry.hub.docker.com
我认为 hub.docker.com
index.docker.io
也可以。
在 Docker 正常运行时间状态页面,您将看到这两个域受到监控,并且域名为“registry”。
不幸的是,Docker 并没有说明实际的域是什么,因为它们有很多都做同样的事情。
如果推送到私有存储库,您需要提供注册表主机名 请参阅此处https://docs.docker.com/engine/reference/commandline/image_tag/#tag-an-image-for-a-private-registry