我有许多新的 Docker 镜像,我想将它们推送到 Docker Hub。我已经在 Docker Hub 上创建了所有空仓库,并添加了具有我想要的权限级别的团队和成员。这些用户之一是jenkinsrelease
. 此用户是团队成员,mihbuild
并且mihrelease
. 以一个 repo 为例,meanwhileinhell/search-server
每个团队的权限为mihbuild - Read only
和mihrelease - Read & write
。
我正在使用bmuschko
Gradle 的 Docker API 插件从运行 Ubuntu 的 EC2 从属实例构建和推送图像,该实例由我的 Jenkins 构建创建。但是,每当我尝试将图像推送到 Docker Hub ( ./gradlew dockerPushImage
) 时,都会出现以下错误:
> Task :search-server:dockerPushImage FAILED
Pushing image 'meanwhileinhell/search-server:0.0.1-SNAPSHOT'.
* What went wrong:
Execution failed for task ':search-server:dockerPushImage'.
> Could not push image: denied: requested access to the resource is denied
我已经在命令行登录 Docker 并说我已成功登录:
docker login -u jenkinsrelease -p pasword1234
Login Succeeded
查看我的config.json
,我可以看到auth
更新的部分:
-rw------- 1 ubuntu ubuntu 184 Sep 2 08:31 /home/ubuntu/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "wrjauhgfoihfwu1y2tyed6uyiom="
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.06.3-ce (linux)"
}
}
我也尝试过注销并再次登录,并登录registry-1.docker.io
并将index.docker.io/v2
相应的条目添加到config.json
. 我试图登录hub.docker.com
但它报告了一个错误(我知道这与 相同docker.io
):
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "wrjauhgfoihfwu1y2tyed6uyiom="
},
"index.docker.io": {
"auth": "wrjauhgfoihfwu1y2tyed6uyiom="
},
"registry-1.docker.io": {
"auth": "wrjauhgfoihfwu1y2tyed6uyiom="
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.06.3-ce (linux)"
}
}
我不知道它是否有所不同,但这是第一次将图像推送到这些存储库,它们目前都是空的。
的输出docker info
是:
Containers: 3
Running: 0
Paused: 0
Stopped: 3
Images: 65
Server Version: 18.06.3-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 49
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: a592beb5bc4c4092b1b1bac971afed27687340c5
init version: fec3683
Security Options:
apparmor
Kernel Version: 4.15.0-65-generic
Operating System: Ubuntu 18.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 31.41GiB
Name: ip-172-31-37-204
ID: 7WRO:A5BW:TELQ:KBVM:WCVP:HUZC:DHLY:JXYS:WDUV:YQ76:F2VA:H4WG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: jenkinsrelease
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
按顺序运行的完整命令列表是:
docker login -u jenkinsrelease -p password1234
./gradlew clean build
./gradlew dockerBuildImage
./gradlew dockerPushImage