What's the meaning of docker hub's url design? - url

https://registry.hub.docker.com/_/ubuntu/
There is a _ in the url before the product name.
What is it for?

If you have a account on dockerhub called foobar:
# pull from your account (foobar)
docker pull foobar/ubuntu:latest
Otherwise, if you omit the username:
# pull from the official account (library)
docker pull ubuntu:latest
# almost the same as
docker pull library/ubuntu:latest
The underscore(_) is a special namespace used to publish the official repositories.
https://registry.hub.docker.com/_/ubuntu/ is almost the same as https://registry.hub.docker.com/u/library/ubuntu/
The only difference is that you will get different image-names with identical image-id:
$ docker pull ubuntu:latest
$ docker pull library/ubuntu:latest
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
library/ubuntu latest 86ce37374f40 7 days ago 192.7 MB
ubuntu latest 86ce37374f40 7 days ago 192.7 MB

Related

What is docker image reference?

Docker documentation mentions image reference in many places. However, running docker images command gives the list of images with the following properties: REPOSITORY, TAG, IMAGE ID, CREATED, SIZE - no reference. Is 'reference' a synonym for ID or digest, or something else?
The docker image reference is the combination of the REPOSITORY and TAG in this format REPOSITORY:TAG where they are both separated by :. So if you have an image with a REPOSITORY of IMAGE1 and a tag of latest the image reference would be IMAGE1:latest. The knowledge of an image reference would help you to filter by docker image list by reference by running:
docker images --filter=reference='myDocker*:*dev'
The above command will return all docker images that the repository name starts with myDocker and the tag name ends with dev.
To add on to Kelvin's answer, Reference is the Repository which you will use with the tag. Have a look the below example.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest e02e811dd08f 5 weeks ago 1.09 MB
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
busybox musl 733eb3059dce 5 weeks ago 1.21 MB
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
As you can see above, my reference would be respectively
busybox:latest
busybox:uclibc
busybox:musl
busybox:glibc
If you only use the reference as busybox, by default it will use the latest tag.
You can filter the images on the reference filter as well.
docker images --filter=reference='busy*:*libc'
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
You use the image reference in Dockerfile as well when you build the image by using the FROM directive.
FROM busybox #Reference is used as you can see and automatically, `latest` tag will be pulled
...
Ref:- https://docs.docker.com/engine/reference/commandline/images/
Ref:- https://docs.docker.com/engine/reference/builder/#from

How to push an image id to docker repo

When I run the command docker ps I get a list of containers like this:
6f8d5585918f 56058f3d1997 "test" 23 hours ago Up 23 hours test1
18edba56bfeb 2482781314c7 "java -jar test2" 2 days ago Up 2 days 0.0.0.0:8206->8484/tcp test2
The second column is the image. I want to push the second image as test11 to our private repo. I don't have the files to build the image. How would I do this?
First you must tag the image ID. The you must login to your private Docker registry. (The correct name is registry and not repository. A Docker registry holds repositories). Then you push the image.
Substitute privateregistry with the hostname of the Registry.
docker tag 2482781314c7 privateregistry/test11
docker login privateregistry
docker push privateregistry/test11

What is the difference between docker images and docker search commands?

On a coreOS (899.15.0) machine, when I execute docker search and images I get the following results :
docker search private-registry:5000/
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker images on the private registry machine:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest e32087da8ee6dfa45221c48670fa9475f3d8a53a0e9ccabef4f741c62c77d49b 2 weeks ago 182.6 MB
registry 0.9.1 facc02b3acf6f811e8eace6d07b34cd5ab687e926ac5b5231da93264b259f1a4 12 weeks ago 422.8 MB
<none> <none> db81ebdc7ebd3d7aec05d4faa6f4c9c2e35954896e968bce2f90a9736485aa06 3 months ago 422.8 MB
...and a few more images
The reference for docker search mentions that it looks up on docker hub, but since I am specifying a specific registry here, I suppose it is looking up in the private repository.
I am not sure what is the difference between these two commands here and why the difference in results.
You are supposing wrongly. docker search searches only Docker Hub, not private registries. docker images command lists images on the machine (locally built or pulled from registries).
If you want to search or list images in the private registry, you need to use registry API to do so: https://docs.docker.com/registry/spec/api/

can't push or pull to a docker repo `Repository not found`

I am new to docker. created a public repo under my account
link to repo
I am able to pull other public repos like redis and debian:
docker ps ✱
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40416ad4c715 debian:latest "/bin/sh -c 'while t 6 minutes ago Up 6 minutes dal_server
but when trying to pull from my repo i get an error:
docker pull opmaster/basic_server ✱
Pulling repository opmaster/basic_server
FATA[0009] Repository not found
docker push opmaster/basic_server ✱
The push refers to a repository [opmaster/basic_server] (len: 0)
FATA[0000] Repository does not exist: opmaster/basic_server
>> docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
debian latest 41b730702607 10 days ago 125.1 MB
hello-world latest 91c95931e552 3 weeks ago 910 B
>> docker tag 41b730702607 opmaster/basic_server:devel
>> docker push opmaster/basic_server
docker push can get be little long from my short experience, so i stopped it with ctrl-c, did boot2docker restart and started again with the docker push opmaster/basic_server
if someone knows a better way, i'm open to suggestions.
You don't appear to have a valid image on dockerhub. How did you create the image that is there? I see if, but there isn't anything in it.
Your images are created by pushing an image that you have locally, or with a Dockerfile (you can buuild an image). There is a good write up on how to push an image here:
https://docs.docker.com/userguide/dockerrepos/
Once you get a valid image pushed, pulling it will be possible. I have found pushing images (like the one you have listed in your docker ps) is easier to do if you tag it first. However, the easiest way to make images is to create a project for it on github, have a Dockerfile in that project, then auto build it (github checkin triggers a build on dockerhub).

Docker public registry push fails: Repository does not exist

I'm trying to push my docker image up into the public docker registry:
$ docker login
Username (binarybana):
WARNING: login credentials saved in /home/jknight/.dockercfg.
Login Succeeded
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
binarybana/dev-fedora latest 10c7881fbaca 24 hours ago 1.148 GB
binarybana/fedoradev latest 10c7881fbaca 24 hours ago 1.148 GB
binarybana/fedora-dev latest 10c7881fbaca 24 hours ago 1.148 GB
<none> <none> b44397dc4c99 24 hours ago 1.148 GB
<none> <none> a98c27ba4738 24 hours ago 1.141 GB
<none> <none> 775c74a34add 24 hours ago 1.141 GB
<none> <none> 2be2491d2354 24 hours ago 1.141 GB
docker.io/fedora 21 93be8052dfb8 7 days ago 241.3 MB
$ docker push binarybana/dev-fedora
Do you really want to push to public registry? [Y/n]: Y
The push refers to a repository [docker.io/binarybana/dev-fedora] (len: 0)
FATA[0001] Repository does not exist: docker.io/binarybana/dev-fedora
$ docker push binarybana/fedora-dev
Do you really want to push to public registry? [Y/n]: Y
The push refers to a repository [docker.io/binarybana/fedora-dev] (len: 0)
FATA[0002] Repository does not exist: docker.io/binarybana/fedora-dev
Yet, I've already created the repository (viewable here). And I've also tried to push to repository names that I haven't already created (the first try in the example above).
I think the (len: 0) has something to do with it, but I can't google it. Also I originally created the image from a dockerfile as:
docker build -t binarybana/fedora-dev .
Thanks.
Always build your image with "username" and "tag"
docker build -t <username>/dev-fedora:latest .
After building push the image
docker push <username>/dev-fedora:latest
if you are using docker.io ( dockerhub repo ), you need to tag it including the name docker.io in it.
docker tag ${image_id} docker.io/${login_name}/${image_name}
and then
docker push docker.io/${login_name}/${image_name}
is OK.
I also encountered this error Repository does not exist: gcr.io/my-project-id/my-container when attempting to push an image to Google Container Registry.
My confusion came from a misunderstanding of Docker's definition of "repository".
A repository is a set of Docker images. A repository can be shared by pushing it to a registry server. The different images in the repository can be labeled using tags.
When Docker says that a repository does not exist, it means that there is no image that it can find locally that is tagged with that registry.host/user-name/image-name combination.
Note: The Docker Hub registry is the default, so that part can be omitted if you are pushing there.
Steps to fix this issue:
Double check what images you have available locally.
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
gcr.io/my-proj/my-typo v1 40c2ae2dedb8 2 days ago 427.8 MB
If there is a typo, you can run the docker tag command to fix it.
$ docker tag gcr.io/my-proj/my-typo:v1 gcr.io/my-proj/my-cntr:v1
Now, you should be able to push the image using the complete name, including the tag.
$ docker push gcr.io/my-proj/my-cntr:v1
Note: Use gcloud docker -- push instead of docker push if you are pushing to the Google Container Registry.
If you are using Amazon AWS, before you can push your Docker images to Amazon ECR, you need to create a repository to store them in. You can create Amazon ECR repositories with the AWS Management Console, or with the AWS CLI and AWS SDKs.
To create a repository
1.) Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.
2.) From the navigation bar, choose the region to create your repository in.
3.) On the Repositories page, choose Create repository.
4.) For Repository name, enter a unique name for your repository and choose Next step.
5.) Now you should be able to push to your AWS repo!
You need to use the complete image name. When you don't specify the tag while building, it's latest, so you should say
docker push binarybana/fedora-dev:latest
Adding to Santosh Gandhe's answer, if you want to push to specific repository rather than under your login name
docker tag ${image_name} docker.io/${login_name}/${remote_repo_name}:${image_name}
and then
docker push docker.io/${login_name}/${remote_repo_name}:${image_name}
Also, don't forget to do docker login first.

Resources