'Why can't push the new created image into docker-hub?
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?
Solution 1:[1]
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
Solution 2:[2]
Leave out the docker.io in the end for the login command. Like this:
docker login -u "myusername" -p "xxxxxxxx"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BMitch |
| Solution 2 | ino |
