Why can't push the new created image into docker-hub? - docker

I want to create my own image and push it into my docker-hub.
Prepare:
mkdir /tmp/mydebian
cd /tmp/mydebian
vim mydebian.Dockerfile
#all contents omitted here
Build the image with Dockerfile:
docker build -f mydebian.Dockerfile --tag=mydebian:0.0.1 .
Check it:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mydebian 0.0.1 bd66705654b1 5 minutes ago 460MB
Login docker:
docker login -u "myusername" -p "xxxxxxxx" docker.io
Push now:
docker push myusername/mydebian:0.0.1
The push refers to repository [docker.io/myusername/mydebian]
An image does not exist locally with the tag: myusername/mydebian
Try other format:
docker push mydebian:0.0.1
The push refers to repository [docker.io/library/mydebian]
690c901c038e: Preparing
1155352a0b68: Preparing
1201adb8bea9: Preparing
a13c519c6361: Preparing
denied: requested access to the resource is denied
How can fix it?

You need to tag your images with the name they'll be pushed with. Either on build:
docker build -f mydebian.Dockerfile --tag=myusername/mydebian:0.0.1 .
Or to give an existing image an additional tag:
docker tag mydebian:0.0.1 myusername/mydebian:0.0.1

Leave out the docker.io in the end for the login command. Like this:
docker login -u "myusername" -p "xxxxxxxx"
Same error with a longer description

Related

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?

docker push give me that error: "an image does not exist locally with the tag"

I'm trying to push an image that is hosted in another project with that command:
docker login [first account with service-account]
docker pull gcr.io/xxx/xxx/xxx:1.0.0
docker login [other service-account]
docker push gcr.io/yyy/yyy/yyy:1.0.0
and that give me that error:
An image does not exist locally with the tag: gcr.io/yyy/yyy/yyy
How I can fix it? I altro tried to tag the image locally but has now worked
You can simply tag your XXX Docker image as YYY, for example:
# Pull image XXX
docker login [first account with service-account]
docker pull gcr.io/xxx/xxx/xxx:1.0.0
# Tag it as YYY
docker tag gcr.io/xxx/xxx/xxx:1.0.0 gcr.io/yyy/yyy/yyy:1.0.0
# Push it on the other account
docker login [other service-account]
docker push gcr.io/yyy/yyy/yyy:1.0.0
Your command fails because Docker does not recognize that gcr.io/yyy/yyy/yyy:1.0.0 is the same as gcr.io/xxx/xxx/xxx:1.0.0 - you must specifically tell-it so by tagging such as above.

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

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