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
Related
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.
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.
I am trying to push docker image into docker hub, but i am not able to push docker image into docker hub.
You need to push in the following manner (ensure you are logged into docker on the command line)
docker push <dockerusername>/test-img:<tag>
Make sure you also build your image as:
docker build -t <dockerusername>/test-img <Dockerfile>
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
I'm migrating a project from a private registry to hub.docker.com but I don't have all tagged image on computer.
I have access to the registry machine via SSH.
Question
How can I push all my registry images to hub.docker.com?
I think that the only way is to pull them all, then retag them and push to hub.docker.com
You can script it with something like:
for repository in $(curl -s http://localhost:5000/v2/_catalog | jq -r '.repositories[]'); do
for image in $(curl -s http://localhost:5000/v2/${repository}/tags/list | jq -r '(.name + ":" + .tags[])')
docker image pull localhost:5000/${image}
docker image tag localhost:5000/${image} <YOUR_HUB_PREFIX>/${image}
docker image push <YOUR_HUB_PREFIX>/${image}
# if you need some cleanup
docker image rm localhost:5000/${image} <YOUR_HUB_PREFIX>/${image}
done
done
Access to your registry machine via SSH, use docker login to login inside your Docker Hub account, add a tag to your images which points to Docker Hub docker tag my_own_registry.com/image:tag user/image:tag a then push that new tag using docker push user/image:tag.
#zigarn script automates this job.
Edit: You commented that your bandwith is bad, then you can access via ssh to your registry machine, save your image using docker save, then copy it to your machine and load it by docker load and finally push it to Docker Hub as explained above.