Can't push an image to Openshift (unauthorized: authentication required) - docker

I'm new to Openshift and Docker.
I created a new project on Openshift, and a new image stream as well so I can push a docker image I created to the docker repository inside my Openshift project.
After login in with docker to the registry as explained in the Openshift documentation, and getting a Login succeded message, I went ahead to tag my image, and push it to the image stream, only to get a message stating Unauthorized: authentication required.
sudo docker login -u `oc whoami` -p `oc whoami -t` registry.starter-us-east-1.openshift.com
sudo docker tag test:latest registry.starter-us-east-1.openshift.com/rolabot/test
sudo docker push registry.starter-us-east-1.openshift.com/rolabot/test
This last command returns
3ea53db680fc: Pushing [==================================================>] 12.8 kB
54f43adb4662: Pushing 1.536 kB
49907af65b0a: Pushing [==================================================>] 3.072 kB
4589f96366e6: Pushing [==================================================>] 5.632 kB
b97229212d30: Pushing 14.85 kB
cd181336f142: Waiting
0f5ff0cf6a1c: Waiting
unauthorized: authentication required

To me, it seems like this is an issue with the upstream Docker Registry cache in Origin. This seems to be a known issue in minishift, but the remedies they have found are not possible (as you don't have the necessary permissions) on Openshift Online. I would open a new support ticket with Red Hat, so that they can take a look.

Related

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.

Why can I not push new docker build to DockerHub repo

So I create a Docker hub image as follows, worked fine
Created new empty repository in DockerHub
Uploaded my DockerFile to my webserver
ssh *qnapserver*
docker build *DockerFileUrl*
docker login *DockerHubUsername* *DockerHubPassword*
docker images (to get imageId of built image)
docker tag *imageId* *DockerHubNameSpace*/*DockerHubRepository*:latest
docker push *DockerHubNameSpace*/*DockerHubRepository*:latest
A few weeks later I need to rebuild image for new software version, so I did
ssh *qnapserver*
docker build *DockerFileUrl*
docker login *DockerHubUsername* *DockerHubPassword*
docker images (to get imageId of built image)
docker tag *imageId* *DockerHubNameSpace*/*DockerHubRepository*:latest
docker push *DockerHubNameSpace*/*DockerHubRepository*:latest
but the final push command fails with
The push refers to a repository [docker.io/songkong/songkong-arm32]
d68f3fa1b903: Preparing
a0fcc8fd26d0: Preparing
e921eb3da019: Preparing
30b60a45df09: Preparing
8a9717d91a27: Preparing
fcf19287cca0: Waiting
72b719a20b26: Waiting
denied: requested access to the resource is denied
Running docker images gives:
[~] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
songkong/songkong-arm32 latest d2ab52ce970a 14 minutes ago 179MB
arm32v6/openjdk 8-jre-alpine d6163b61a7aa 8 days ago 72.9MB
songkong/songkong-arm32 <none> a57032901b5c 2 weeks ago 169MB
songkong/songkong-arm32 <none> 8f3ae4b75feb 2 weeks ago 162MB
The issue seems to be that I wasnt logged onto DockerHub properly
docker login *DockerHubUsername* *DockerHubPassword*
did not return an error, but I tried doing
docker login
and entering username and password at the prompt and then the push worked ok.
Are you using Docker for Mac ?
There is a bug with the docker login CLI command.
Please see this github issue and add your experience if you can :
https://github.com/docker/for-mac/issues/2016

Access denied when pulling Docker image from a repository I own

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

GKE: Docker login alway succeeds, but push does not work even with valid credentials

I have a GKE cluster running in GCE, I was able to build + tag an image derived from ubuntu:16.04:
/ # docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
eu.gcr.io/my-project/ubuntu-gcloud latest a723e43228ae 7 minutes ago 347MB
ubuntu 16.04 ebcd9d4fca80 7 days ago 118MB
First I try to log in to registry (as documented in GKE docs)
docker login -u oauth2accesstoken -p `curl -s "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" -H "Metadata-Flavor: Google"|awk -F\" "{ print \$4 }"` eu.gcr.io`
And then the docker push command fails:
# docker push eu.gcr.io/my-project/ubuntu-gcloud
The push refers to a repository [eu.gcr.io/my-project/ubuntu-gcloud]
a3a6893ab23f: Preparing
6e390fa7d62c: Preparing
22b8fccbaf84: Preparing
085eeae7a10b: Preparing
b29983dd2306: Preparing
33f1a94ed7fc: Waiting
b27287a6dbce: Waiting
47c2386f248c: Waiting
2be95f0d8a0c: Waiting
2df9b8def18a: Waiting
denied: Unable to create the repository, please check that you have access to do so.
The token should be valid, in another instance I'm able to gcloud whatever with it; the service account has 'Editor' role on the project.
The weirdest part is when I do docker login with obviously invalid credentials
misko#MacBook ~ $ docker login -u oauth2accesstoken -p somethingverystupidthatisreallynotmypasswordortoken123 eu.gcr.io
Login Succeeded
login always succeeds.
What shall I do to successfully docker push to gcr.io?
Try this:
gcloud docker -- push eu.gcr.io/my-project/ubuntu-gcloud
If you want to use regular docker commands, update your docker configuration with GCR credentials:
gcloud docker -a
Then you can build and push docker images like this:
docker build -t eu.gcr.io/my-project/ubuntu-gcloud .
docker push eu.gcr.io/my-project/ubuntu-gcloud

Docker cloud repository push: access to the requested resource is not authorized on Fedora 23

I've just come over from tutum and and am trying to deploy to a docker cloud repository. I've created the repository and have tagged an existing image:
docker tag deploy foo/rtb
When I attempt to push my tagged image up like so:
docker push foo/rtb
I get this:
The push refers to a repository [docker.io/foo/rtb] (len: 0)
18118bb6b8ef: Preparing
unauthorized: access to the requested resource is not authorized
The repository exists and I've logged in to docker. Is there something I'm missing?
Interestingly enough, if I try to delete the image I get an error like this:
Error response from daemon: conflict: unable to delete 18118bb6b8ef
(must be forced) - image is referenced in one or more repositories
Error: failed to remove images: [18118bb6b8ef]
I had been using docker 1.9.1. That's the version in the Fedora 23 repo.
The kind folks at docker tech support recommended I upgrade to the latest 1.10.3
Upgrading then doing
docker logout
followed by
docker login
fixed everything up.
Did you tag your image ?
docker build --tag docker.io/<yourdockerhubname>/<appname> .
docker build --tag docker.io/moskalr/rtb .
docker push docker.io/<yourdockerhubname>/<appname>
docker push docker.io/moskalr/rtb
the push should respond with something which mentions the dockerhub image name

Resources