Cannot push Docker images to Docker Hub; requested access to the resource is denied

581 views Asked by At

I have a number of new Docker images that I want to push up to Docker Hub. I have created all the empty repos on Docker Hub, and added the teams and members with the privilege level I want. one of those users is jenkinsrelease. This user is a member of the team mihbuild and mihrelease. Using one repo as an example, meanwhileinhell/search-server, the permissions for each team are mihbuild - Read only and mihrelease - Read & write.

I am using the bmuschko Docker API plugin for Gradle to build and push images from an EC2 slave instance running Ubuntu that was created by my Jenkins build. However, whenever I try to push an image up to Docker Hub (./gradlew dockerPushImage), I get the following error:

> 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

I have logged into Docker on the command line and says I'm logged in successfully:

docker login -u jenkinsrelease -p pasword1234

Login Succeeded

Looking at my config.json, I can see the auth section updated:

-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)"
        }
}

I have also tried logging out and back in again, and also logging into registry-1.docker.io and index.docker.io/v2 which added the corresponding entries into the config.json. I tried to log into hub.docker.com but it reported an error (I know that this is meant to be the same as 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)"
        }
}

I don't know if it makes a different, but this is the first time an image will have been pushed to these repos, they are all currently empty.

Output of docker info is:

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

Full list of commands run in order are:

docker login -u jenkinsrelease -p password1234
./gradlew clean build
./gradlew dockerBuildImage
./gradlew dockerPushImage
1

There are 1 answers

0
MeanwhileInHell On

This was a bug in the version of the bmuschko Docker plugin used. Was on 6.1.2, updating to 6.6.1 resolved the issue.