How to pull a single image from any docker repository? - docker

The docker repositories contains multiple images. Is it possible to just pull the specific image from Repository.
When I use:
docker pull ubuntu
It pulls down around 8-10 different versions of ubuntu.

If there's a specific image that's tagged, you could use the --tag= (or -t) operator to pull the specific image you're looking for. There's a shorthand form for the command as well, which uses just a colon between the image name and the tag.
So if you want the version of ubuntu that's tagged as quantal, you could use:
docker pull ubuntu:quantal
The longer forms would be:
docker pull --tag="quantal" ubuntu
docker pull --t quantal ubuntu
This will still pull the historical layers used to build the final image, but will be a smaller subset than all of the layers for ubuntu.
[Updated to include Ben's note on shorthand from below. Thanks!]

You can also use
docker pull reponame:tagname
docker pull ubantu:quantal

Related

What is the difference between docker pull and docker image pull commands?

As of now, I am learning Docker. This reference has mentioned two ways of pulling an image from the Docker registry. Can anyone explain this in simple terms?
Does this mean that we cannot get updates on a pulled image if we use docker image pull command?
They are the same command. From the documentation you linked:
To download a particular image, or set of images (i.e., a repository), use docker image pull (or the docker pull shorthand).
There are many "shortand commands" like:
docker push for docker image push
docker run for docker container run
...
What is the difference between docker pull and docker image pull commands?
None.
Can anyone explain this in simple terms?
They are the same.
Does this mean that we cannot get updates on a pulled image if we use docker image pull command?
No.
Also https://forums.docker.com/t/docker-pull-imagename-vs-docker-image-pull-imagename/59283

ubuntu-core as container os in base image

I'm currently reviewing possible solutions for container operation systems for our applications. I'm considering RancherOS and Ubuntu-Core. But since we are using docker base images, I'm a little confused how to create a docker base image with ubuntu-core. I can't find an official release candidate from canonical and I don't want to create it myself from a tag. How could I compose the base image?
I can't find an official release candidate from canonical
Yes, there is no officaial image on dockerhub, but this & some other high pull images are good to use I think.
How could I compose the base image
If you still do not want to use the images on docker hub. Then in fact you still can form your own docker image based on official ubuntu-core release like next:
Download Ubuntu Core based on 14.04 version
wget http://cdimage.ubuntu.com/ubuntu-core/trusty/daily/current/trusty-core-ppc64el.tar.gz
Import the files into docker
# cat trusty-core-ppc64el.tar.gz | docker import - ubuntucore
3ad6c6616b921b10a414238a226fb39eef85d8249ac7d767e84e275aaf90ab65
Guarantee that the image was created:
# docker images
Assure that your image is running fine:
# docker run ubuntucore ls
Detail refers to IBM guide, and, if you need to use the new version, you also can find it in http://cdimage.ubuntu.com/ubuntu-core

docker pull wouldn't pull latest image from remote

I ran this:
docker pull 91xxxxx371.dkr.ecr.us-west-2.amazonaws.com/main_api
and nothing new was pulled, but I knew there were new images on AWS/ECR.
So I removed the existing images:
docker rmi 91xxxxx371.dkr.ecr.us-west-2.amazonaws.com/main_api
and then pulled again and of course it says it retrieved new images, but that's probably just because I deleted the local tags/images or whatever.
Why didn't the first pull command get the latest? It defaults to the latest tag.
Update:
I have to correct my answer, #David Maze (comment) is right: I described the docker run behaviour.
From the Docker documentation:
When using tags, you can docker pull an image again to make sure you have the most up-to-date version of that image
So your command should work, I don't know why it's not working, sorry.
But nevertheless you can use as a workaround tags to enforce to pull the image with the specified tag.
docker run (not docker pull) search first in your local registry on your machine. If there is the image with the tag latest, the search is satisfied and terminated. If the image with the given tag is not available in your local registry, then docker will search in a remote registry like docker hub or your own.
So the tag latest should be used with care. If you have an Image with the tag latest in your local registry then you have to delete it first, so docker get nothing and search in remote registry.

How can I find the images being pulled from the SHA1s?

When we run a docker container if the relevant image is not in the local repo it is being downloaded but in a specific sequence i.e parent images etc.
If I don’t know anything about the image how could I find from which images is being based on based on the layers pulled as displayed in a docker run?
The output only shows the SHA1s on any docker run etc
AFAIK, you can't, there is no reverse function for a hash.
Docker just tries to get the image from local, when its not available tries to fetch it from the registry. The default registry is DockerHub.
When you don't specify any tag when running the container ie: docker run ubuntu instead of docker run ubuntu:16.04 the default latest is used. You'll have to visit the registry and search which version the latest tag is pointing to.
Usually in DockerHub there is a link pointing the GitHub repo where you can find the Dockerfile, in the Dockerfile you can find how its built, including the root image.
You also can get some extra info with docker image inspect image:tag, but you'll find more hashes in the layers.
Take a look to dockerfile-from-image
"Similar to how the docker history command works, the dockerfile-from-image script is able to re-create the Dockerfile (approximately) that was used to generate an image using the metadata that Docker stores alongside each image layer."
With this, maybe you can get the source of the image.

Find what tags will be downloaded with `docker pull ubuntu`

When I run in docker 1.2 docker pull ubuntu a lot of tags are downloaded. (In the version 1.3 this was changed — to download all the tags I need to run docker pull ubuntu --all-tags
I know that I can see the tags what are going to be downloaded on the Docker Hub — https://registry.hub.docker.com/_/ubuntu/tags/manage/
Is there a way to find out the list of tags that are to be downloaded from docker console utilities?
Docker pull without an explicit tag will pull the "latest" tag. If you call pull with "--all-tags" flag it should then pull all the tags for that image.
Documentation for docker pull is here:
https://docs.docker.com/reference/commandline/cli/#pull

Resources