Access denied when pulling Docker image from a repository I own - docker

I built a Docker image that I pushed to Docker Hub under my account and removed locally after. But when I try to pull it, it throws the following error:
Error response from daemon: pull access denied for mightyspaj/dockerfile-assignment-1, repository does not exist or may require 'docker login'
I'm logged into the same account that owns the repository for this image and can perform other tasks (such as pushing) perfectly fine. The repository also definitely exists on Docker Hub, yet it fails when I try to pull it.
I've tried the following things:
Logging out of my account and back in again
Renaming config.json and regenerating it
Running an isolated Docker container with docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock:ro docker sh, then logging into my account and attempting to pull the image
Deleting and recreating the repository
All of these things still produce the same error. I'm baffled.
To note, both my client and engine versions are 17.12.0-ce. My OS is Ubuntu 17.10 (64-bit).
Console output
docker login
-> % docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: mightyspaj
Password:
Login Succeeded
docker tag
-> % docker tag dockerfile-assignment-1:latest mightyspaj/dockerfile-assignment-1
docker push
-> % docker push mightyspaj/dockerfile-assignment-1
The push refers to repository [docker.io/mightyspaj/dockerfile-assignment-1]
8427a8e6a29f: Pushed
655a921743e8: Pushed
8aa44edb7524: Pushed
60f1a2dc4cd8: Mounted from library/node
9185fe936b87: Mounted from library/node
e53f74215d12: Mounted from library/node
latest: digest: sha256:6c68220ba84f13d0229ef4458f22369410bb98764b908a75be0849c3003de160 size: 1582
docker image rm
-> % docker image rm mightyspaj/dockerfile-assignment-1
Untagged: mightyspaj/dockerfile-assignment-1:latest
Untagged: mightyspaj/dockerfile-assignment-1#sha256:6c68220ba84f13d0229ef4458f22369410bb98764b908a75be0849c3003de160
docker image pull
-> % docker image pull mightyspaj/dockerfile-assignment-1
Using default tag: latest
Error response from daemon: pull access denied for mightyspaj/dockerfile-assignment-1, repository does not exist or may require 'docker login'

I could fix the same issue only when I made the repository public. Make sure the repository is public then this is the set of instructions I followed in command line:
Once logout from docker hub and login again.
1- docker logout
2- docker login --username=YOURUSERNAME
Enter password when asked
3- docker pull repositoryName"/"imageName[:tag]
if "tag" is not included the default value will be "latest".
Then check the images by docker images command to check if its been pulled.
After pulling is done I made the repository private again.

This solution is only valid on private docker repositories!!
First try to login on your private repo e.g:
docker login dockerrepo.example.com
Then
If you build new image with dockerfile based on image in your private repository then you must prefix your base image with private repository url:
FROM PRIVATE_REPO_URL + IMAGE_INFO
sample:
PRIVATE_REPO_URL --> dockerrepo.example.com
BASE_IMAGE --> samples/java/jdk:1.6
Your dockerfile look like this:
FROM dockerrepo.example.com/samples/java/jdk:1.6

Related

Build and Push Docker Image to Docker Hub- UnAuthorised

I have a git repository from where I am trying to build and publish a docker image to docker hub.
Some how I am keep on getting Unauthorised for docker login step.
Any Help is appreciated.
GitHub Repo : https://github.com/Git-Beginner/ghaction/actions
You should first login to docker hub by typing the command docker login it will prompt the user name and after that password of docker hub after that try pushing the image again to docker hub
I am not that sure if this is what you have asked for but in order to push images to docker hub , first you need to build your docker image. then create a repository on docker hub with the name you want. and then do something like this
docker build -f ./Dockerfile -t nametoyourlocalimage:version . //this will build your docker image locally
docker tag nametoyourlocalimage:version YourDockerHubNewReporUrlYouJUstCreated
docker login //this will prompt you to enter your username and password
docker push YourDockerHubNewRepoUrlYouJUstCreated
docker logout

I'm able to push my image to my private Docker registry but the 2nd image push is refused

I am no MacOS installed Docker Desktop.
I have a private registry in Docker Hub.
I have two Dockerfiles in my project, each for one image. Both images are built successfully:
# 1st image
docker build -t myusername/my-app:1.0.3 -f Dockerfile .
# 2nd image
docker build -t myusername/my-proxy:1.0.0 -f proxy/Dockerfile .
On terminal, I firstly login with my docker id myusername:
$ docker login -u myusername docker.io
Password:
Login Succeeded
Then, I push my first image:
$ docker push myusername/my-app:1.0.3
The push refers to repository [docker.io/myusername/my-app]
e632ff00a21f: Layer already exists
...
9578c16f3f7c: Layer already exists
3141322c5cdb: Layer already exists
1.0.3: digest: sha256:43c072e10438c545697c54a76f19a41535a9fb0b7cab2a46b737c5dc497587c0 size: 2422
The push is successful!
Then I try to push my second image:
docker push myusername/my-proxy:1.0.0
The push refers to repository [docker.io/myusername/my-proxy]
c65e7e80b99d: Preparing
abcda12ed2f7: Preparing
...
1222101d19dd: Waiting
...
9e6f810a2aab: Waiting
denied: requested access to the resource is denied
However the 2nd image push to docker registry is denied. Why is that? Where could be wrong for my 2nd image push?

Can I pull from private images Docker hub free private repo?

I am trying to pull my private images from Docker hub free private repo.
Here is what I have done.
Verify that myrepo/myimage exists in Docker Hub as private image.
Run the following
$ docker login docker.io -u myusername
Password:
WARNING! Your password will be stored unencrypted in /home/sha/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ docker push myusername/xxx-test:latest
The push refers to repository [docker.io/myusername/xxx-test]
e836ed963202: Pushed
24769bc5b044: Pushed
75b121557396: Pushed
4075573f4aa9: Pushed
fa6f238ab393: Mounted from myusername/multi-worker
d6100d978ba2: Mounted from myusername/multi-worker
88b43919be61: Mounted from myusername/multi-worker
0fcbbeeeb0d7: Mounted from myusername/multi-worker
latest: digest: sha256:985d3ed5e09915d5c84431243d511798ac4219a69ca3e73c6514dcb903b32853 size: 1990
$ docker pull myusername/xxx-test:latest
Error response from daemon: pull access denied for myusername/xxx-test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Howver, Docker hub showed it had been pulled.
I have searched SO and googled on the same topic and tried all their suggestions. Nothing worked so far. It will work only if I go to the image settings an make it public.
Any input?
Update
Following the login command I immediately did a push, which was successful.
Then immediately did a pull for the same image, which failed.

How to pull from docker hub - pull access denied repository does not exist or may require 'docker login'

I have pulled images from Docker before - some time ago - but now it seems things have changed.
Take for example https://hub.docker.com/r/datagrip. Documentation states installation as follows
docker pull sath89/oracle-xe-11g
This no longer works with current Docker hub. I can try latest
[myuser:~] $ docker pull sath89/oracle-xe-11g
Using default tag: latest
Error response from daemon: pull access denied for sath89/oracle-xe-11g, repository does not exist or may require 'docker login'
Or tag 11.2
[myuser:~] 1 $ docker pull sath89/oracle-xe-11g:11.2
Error response from daemon: pull access denied for sath89/oracle-xe-11g, repository does not exist or may require 'docker login'
Of course I can try login - login succeeds but pulling images is still not working.
[myuser:~] 1 $ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: mydockerhubuser
Password:
WARNING! Your password will be stored unencrypted in /home/myuser/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[myuser:~] $ docker pull sath89/oracle-xe-11g:11.2
Error response from daemon: pull access denied for sath89/oracle-xe-11g, repository does not exist or may require 'docker login'
[myuser:~] 1 $
What is the secret nowadays for pulling images from Docker hub? It used to be so easy. Too easy clearly.

denied: requested access to the resource is denied - Docker

I am new to Docker and trying to push the Docker image to the hub..giving me the below error.
docker container run hellowold
This is v2
docker image tag hellowold:2 prateekaxyz/hellowold:latest
docker login http://hub.docker.com --username=prateek512
Password:
Login Succeeded
docker push prateekaxyz/hellowold:latest
The push refers to a repository [docker.io/prateekaxyz/hellowold]
93351e248e6e: Preparing
298c3bb2664f: Preparing
73046094a9b8: Preparing
denied: requested access to the resource is denied
You need to first tag your image before pushing
docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage
And then you can push it.
docker push YOUR_DOCKERHUB_NAME/firstimage
reference: https://intellipaat.com/community/207/denied-requested-access-to-the-resource-is-denied-docker
you should login first. suppose you have an account in https://hub.docker.com/
as name/password= prateekaxyz/bar.
before push, you should
docker login -u prateekaxyz -p bar
after login success, you can push image to docker hub under your namespace
note that your image should begin with your name, eg prateekaxyz/aa:version
This helped me:
Build the image with the following format:
docker build -t [docker-id]/reponame .
which will by default be given "latest" as tag
and then run:
docker push [docker-id]/reponame:latest

Resources