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

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/

Related

How to reconnect to default docker engine

I have installed docker on my Windows 10, then I've created some images.
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 2cb0d9787c4d 3 weeks ago 1.85kB
Then I created my first machine using docker-machine create connected to hyperv driver.
so when I do docker images I get:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
My question is how can I reconnect to the default docker engine so if I run docker images I get:
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 2cb0d9787c4d 3 weeks ago 1.85kB
try image instead of images
docker image list
There seems to be some inconsistency w.r.t the two i.e. image/images. Though one would expect the output to be same but there are few differences.

Is it possible to store the public docker images in private docker registry

For company rules, our VMs can not access internet (can not use http proxy too). I installed a kubernetes cluster by downloading rpm packages and docker images as below:
k8s.gcr.io/kube-apiserver-amd64:v1.11.0
k8s.gcr.io/kube-controller-manager-amd64:v1.11.0
k8s.gcr.io/kube-scheduler-amd64:v1.11.0
k8s.gcr.io/kube-proxy-amd64:v1.11.0 k8s.gcr.io/pause-amd64:3.1
k8s.gcr.io/etcd-amd64:3.2.18 k8s.gcr.io/coredns:1.1.3
quay.io/coreos/flannel:v0.10.0-amd64
Then i install the rpm packages and load these docker images into all VMs. This can successfully install kubernetes although it's hard working.
My question is that Can i use a private docker registry to store these k8s.gcr.io, quay.io and other public registries' images and each VM's docker.service can pull these images like my private images?
There are several solutions:
Since your machines don't have internet connection and you want use the same images names - you need to provide internet to them. It could be done with any PROXY server, like squid or something else. In this case, you'll need to reconfigure docker to make it work behind the proxy
Deploy any local registry solution (e.g Artifactory) and then use it as a mirror for docker
P.S: I am not insisting on using Artifactory, but it could be very convenient. Look, Artifactory provides the ability to create virtual registry. You can agregate another registries (k8s.gcr.io, quay.io, whatever) "under" this virtual one and use it for docker mirror after.
Yeah you should be able to, as long as you have a machine connected to both the public repo and your private repo. You pull the image down from public, tag it, and push to your repo with docker push. ex with ubuntu from https://blog.docker.com/2013/07/how-to-use-your-own-registry/
# First, make sure you have the "ubuntu" repository:
docker pull ubuntu
# Then, find the image id that corresponds to the ubuntu repository
docker images | grep ubuntu | grep latest
ubuntu latest 8dbd9e392a96 12 weeks ago 263 MB (virtual 263 MB)
# Almost there!
# Tag to create a repository with the full registry location.
# The location becomes a permanent part of the repository name.
docker tag 8dbd9e392a96 localhost.localdomain:5000/ubuntu
# Finally, push the new repository to its home location.
docker push localhost.localdomain:5000/ubuntu

Docker-compose and Docker-swarm

I'm using docker-compose and docker swarm. I have created a docker-mgt server from which I did a docker-machine to setup a swarm cluster consisting of a swarm master and two swarm-agents.
I have created an Express app that gets started in a container and it seems the swarm master decided to have it on agent1. Then I have also a Wordpress site (example from the docker compose site) that I'm running with docker-compose on Docker Swarm.
cloud-user#docker-mgt:~/wordpress$ docker-compose up
wordpress_db_1 is up-to-date
Creating wordpress_web_1
ERROR: Error: image library/wordpress_web:latest not found
The following images are available:
cloud-user#docker-mgt:~/wordpress$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
orchardup/php5 latest c385b8a81cee 18 months ago 330.1 MB
swarm latest a9975e2cc0a3 19 hours ago 17.15 MB
orchardup/mysql latest 5a45a5a953bb 16 months ago 292.4 MB
wordpress_web latest e484f88dc8c8 11 minutes ago 350.9 MB
node-ip latest d177af00338b 39 minutes ago 549.5 MB
centos centos6 1a895dd3954a 8 weeks ago 190.6 MB
So it does have the wordpress_web:latest available and still it complains.
When running this wordpress app on a seperate docker host (not part of the swarm cluster) it runs just fine. To exclude a mistake on the wordpress app, I also tried another complete different app consisting of two containers (with docker-compose) and it is exactly the same issue.
I'm beginning to think that docker compose and swarm can not work together smoothly but that's hard to believe of course.
You might want to try out Rancher, it uses compose and makes it simple to deploy applications across broad types of infrastructure, while keeping native docker syntax and using compose. GitHub Website
The problem is that swarm needs some way to retrieve the image to run the container. If the image doesn't exist in a registry (or the docker hub) then it doesn't (currently) have any way to get that image , and you end up with this error.
One option is to tag the images with a full name and push them to the hub. Then swarm will be able to pull the images on all the nodes.
Another options is to propagate the image using docker save and docker load, which will send the image to all nodes.
Another option is to add an image affinity to force the container to run on the node that has the image.
In the future, swarm should gain the ability to propagate images between nodes.

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.

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

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

Resources