denied: requested access to the resource is denied - docker

I wrote gitlab-ci.yml file.
I Login to gitlab registry with this command
docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
and in the next step build the docker image
docker build -t $REGISTRY .
But When i push docker image
docker push $REGISTRY
I get this error
denied: requested access to the resource is denied
How can fix this error?

Gitlab is probably not finding any repository of the same name as the registry you're trying to push to.
For example if you do docker push gitlab.helloworld.com/prefix/repo-name, then you need to have a project prefix/repo-name
You can read about more about this issue here

tag the image with {{username}}/{{imagename}}:{{version}}
docker login
docker push {{username}}/{{imagename}}:{{version}}

Related

Able to pull acr images but unable to check manifest

I want help in understanding how docker pull works for acr images. I have a private acr repository.
So i run az acr login -n <repo> --expose-token --output tsv --query accessToken to print out the access token.
Then i use this access token to login through docker: docker login <repo>.azureacr.io --username 00000000-0000-0000-0000-000000000000 --password '<ACCESS TOKEN>'. The login works.
Then i try pulling the docker image: docker pull <image>:<tag> which works, but when i do docker manifest inspect <image>:<tag> it fails with the following exception:
errors:
denied: requested access to the resource is denied
unauthorized: authentication required
Questions:
How do i check what permissions I have/need to run these docker commands?
If docker pull is working is it wrong to assume docker manisfest inspect will also work? I mean docker somehow needs to check if the image with the tag exists before pulling it right?

Can't build docker image: "requested access to the resource is denied"

I can't push my docker image to my docker hub repository.
I am logged in. The repo exists and is public. I tried multipled ways of building/tagging/pushing my image.
docker login -u username -p password
docker build ./ -t my-image -f devops/Dockerfile
docker tag image username/my-image
docker push username/my-image
I crawled tens of questions on multiple websites. The answers were always either how to login correctly or how to tag and push the image. It seems to me like I am doing both correctly, so what's wrong?
Did you login with with your docker command ? something like this
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
I guess you need to set the :latest tag on your image. And try to push it with the :latest tag. Also make a correct naming of the container.
Note that only a-z0-9-_. are allowed when naming images:
docker tag myImage myusername/myimage:latest
docker push myusername/myimage:latest
I did it this way and it worked for me.
Here is my example bash script for automate the image taging after a successful build and push it to the docker hub.
#!/bin/bash
docker build -t myusername/myimage:latest .
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push myusername/myimage:latest
docker tag myusername/myimage:latest myusername/myimage:1
docker push myusername/myimage:1
docker tag myusername/myImage:latest myusername/myimage:1.1
docker push myusername/myImage:1.1
docker tag myusername/myimage:latest myusername/myimage:1.1.1
docker push myusername/myimage:1.1.1
I usually only write
docker login
which then requests that you enter your details or says that it's using your existing details that have been saved in the system. Otherwise, I can't see any problems with your commands.
I'm not sure that just writing docker login will make any difference but can't see any other differences.

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

Creating tag for image pushing to repository

I have created repository in docker cloud andrejvi/andrejvi_repo and would like to place there image I have created.
Image name is dev_centos32
I do push:
sudo docker push andrejvi/dev_centos32
According to my understanding I must create tag for this image. How to do that?
Trying to push:
sudo docker push andrejvi/andrejvi_repo:dev_centos32
got error:
An image does not exist locally with the tag: andrejvi/andrejvi_repo:
UPD
I changed tag, but still can't push to repository
docker tag dev_centos32 andrejvi/andrejvi_repo/dev_centos32
sudo docker push andrejvi/andrejvi_repo/dev_centos32
The push refers to repository [docker.io/andrejvi/andrejvi_repo/dev_centos32]
0afb6e2f03f2: Preparing
d70d6ed6bc21: Preparing
denied: requested access to the resource is denied
UPD
Got error while login
$ sudo docker login andrejvi
Username: andrejvi
Password:
Error response from daemon: Get https://andrejvi/v2/: dial tcp: lookup andrejvi on 127.0.1.1:53: server misbehaving
denied: requested access to the resource is denied
You need to login into Docker Hub/Docker Cloud repository using the command:
docker login
Take a look at Push images to Docker Cloud.
Try:
docker login
docker tag dev_centos32 {docker-hub-username}/andrejvi/andrejvi_repo/dev_centos32
docker image push {docker-hub-username}/andrejvi/andrejvi_repo/dev_centos32

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

Resources