Docker pull: still having old image after pull - docker

I noticed that the docker image I'm using is older than the one on dockerhub. Running docker pull seems to work, but later when running docker images I still see the old image, even if I first explicitly removed it with docker rmi.
Output of docker pull:
# docker pull staltz/ssb-room
Using default tag: latest
latest: Pulling from staltz/ssb-room
9a0b0ce99936: Already exists
db3b6004c61a: Already exists
f8f075920295: Already exists
6ef14aff1139: Already exists
0bbd8b48260f: Pull complete
524be717efb1: Pull complete
aad1e8812bc2: Pull complete
13fb072986db: Pull complete
627a2df19018: Pull complete
fb8dcb3732a4: Pull complete
2bc41d47dd50: Pull complete
058f4db9be8e: Pull complete
8f21c57f425d: Pull complete
Digest: sha256:a7c49c796823312f8c1d155eb636bbd974bc55036c2180f16f17d3340fcebbe7
Status: Downloaded newer image for staltz/ssb-room:latest
docker.io/staltz/ssb-room:latest
Output of docker images:
# docker images staltz/ssb-room
REPOSITORY TAG IMAGE ID CREATED SIZE
staltz/ssb-room latest 6097b401900c 4 months ago 930MB
Why is it again showing that 4-months old image?

Related

Docker Registry: Newly tagged image can be found, but not found when pulled

Using :latest image as a base, I have created a new image tagged with :v1.1.0-fermium. After tagging, the newly tagged image :v1.1.0-fermium appears within registry listing of docker images, including :latest
Problem: The :latest image can be pulled from registry, but not the newly tagged :v1.1.0-fermium image, not found registry.
Question: Is there a step I am missing when tagging a docker image in order to be found when pulling from a docker registry?
$ docker image tag docker.foo.com/bar-build:latest docker.foo.com/bar-build:v1.1.0-fermium
$ docker image ls docker.foo.com/bar-build
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.foo.com/bar-build latest 35bfeb2c6323 5 hours ago 5.03GB
docker.foo.com/bar-build v1.1.0-fermium 35bfeb2c6323 5 hours ago 5.03GB
$ docker pull docker.foo.com/bar-build:latest
latest: Pulling from bar-build
$ docker pull docker.foo.com/bar-build:v1.1.0-fermium
Error response from daemon: manifest for docker.foo.com/bar-build:v1.1.0-fermium not found: manifest unknown: The named manifest is not known to the registry.
Kindly Push the docker image into hub.docker.com for publishing it and then you can pull the image.

Pulling from repository

I just created an image :
docker build firstimage .
and tagged it as sohrabp72/firstimage and then pushed it into my repo on the Docker hub:
docker tag firstimage sohrabp72/firstimage
Then I removed the tagged image and the original image from my local machine:
docker rmi sohrabp72/firstimage
docker rmi firstimage
Now when I want to pull the image from the Docker hub repository, my local Docker does not pull it:
C:\Users\Sohrab> docker pull sohrabp72/firstimage
Using default tag: latest
latest: Pulling from sohrabp72/firstimage
cbdbe7a5bc2a: Already exists
9287919c3a0f: Already exists
43a47bbd54c9: Already exists
3c1bcea295c4: Already exists
53e2ab46e733: Already exists
3b08dc288a15: Already exists
e01ad7774a4c: Already exists
Digest: sha256:f16f1cfd9e777898511259e7ff512947c27b7e7bb4f4333dd27bd809bdc77995
Status: Downloaded newer image for sohrabp72/firstimage:latest
docker.io/sohrabp72/firstimage:latest
PS C:\Users\Sohrab>
docker logs show some lines and say already exist. and when I look at images on my local docker, that image is there:
C:\Users\Sohrab> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
getting-started latest bfc5750a86e5 11 hours ago 231MB
sohrabp72/firstimage latest 4e197282638a 22 hours ago 179MB
node 12-alpine d8b74300d554 7 days ago 89.6MB
docker/getting-started latest 1f32459ef038 3 months ago 26.8MB
Is there something like a cache for images we've pushed to Docker hub?
When docker prepares an image, it does step by step and each step creates an intermediate step with an ID. Docker by default removes the intermediate image and the last step provides a final image with an ID.
When you ran build command it actually created a final image with an ID and tagged the final image ID with your name 'firstimage'
When you tag second name, it added additional tag 'sohrabp72/firstimage'
When you ran docker rmi command on both tags, it removed tags only while image created still is there.
You can run
docker images -a
which will list image with <<"none">> in repository and name but final image created will be there with ID
you can
docker image prune -a
to clear all image and try docker pull command

docker pull returning image not found

docker pull localhost:21518/master:latest
Getting following response:
Trying to pull repository localhost:21518/master ...
Pulling repository localhost:21518/master
Error: image master:latest not found
Whereas docker images returns
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:21518/master latest e9f29fbf9931 6 hours ago 703 MB
Why image is not getting pulled?
docker images shows the list of cached images and not repository images. I got confused that docker images showing images from repository as repository is also running on local machine.
Needed to do docker push to get image in repository.

how to get the layers of a docker image on local host

Just started playing with docker on Ubuntu. I pulled a docker image as follows.
docker pull coreos/apache
Now I see there there three layers being pulled.
Using default tag: latest
latest: Pulling from coreos/apache
a3ed95caeb02: Pull complete
5e160ca0bb5a: Pull complete
1f92e2761bfd: Pull complete
Digest: sha256:9af520cee7bedcda564970ff790cdf2e72b6daccce8539f6b3c880ed7fc21091
Status: Downloaded newer image for coreos/apache:latest
From the above, I see that there are three layers for this image.
But now, lets say I close and reopen the terminal, how can I get the layers(same info above) of this image. What is the command?
When I do docker images I get this.
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 0584b3d2cf6d 9 days ago 196.5 MB
hello-world latest c54a2cc56cbb 4 months ago 1.848 kB
coreos/apache latest 5a3024d885c8 2 years ago 294.4 MB
Now that I know the image id, how can I get the layers for that image id.
The tree option as in
docker images --tree
is not working anymore. It seems to be removed. If not one command how can I get that using a sequence of command at least.
If you have the busybox, here is how I would get it.
docker inspect busybox - would show long configuration in json format and below is the excerpt from it to get the layers.
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:e88b3f82283bc59d5e0df427c824e9f95557e661fcb0ea15fb0fb6f97760f9d9"
]
}
You can simple filter it by below command using --format option of docker inspect which would give exactly what OP is looking for.
rao # ubuntu $ docker inspect --format '{{.RootFS.Layers}}' busybox
[sha256:e88b3f82283bc59d5e0df427c824e9f95557e661fcb0ea15fb0fb6f97760f9d9]
now that the image has been downloaded to your local host (in layers), even if you kill your terminal and log back in, the image will still exist on your host. it's downloaded in layers, but resides as an image on your localhost that you can now instantiate into a container using 'docker run'
if you want to pull the image down again and see all the layers being pulled, you can first erase your image (docker rmi ), then do your 'docker pull coreos/apache' again. HTH
edit: to show actual layers that went into an image, run:
docker history <imageid>

Why does "docker push" push several images and where?

I have private repo on docker hub named alek/test.
On my Mac:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
alek/test 0.1 dc1a7cc41129 33 minutes ago 643 MB
node 0.12.7 9e20baae42c8 5 days ago 641.6 MB
$ docker push alek/test
The push refers to a repository [docker.io/alek/test] (len: 1)
dc1a7cc41129: Image successfully pushed
537a913fe639: Image successfully pushed
b40236e9037f: Image successfully pushed
53c8b1d50397: Image successfully pushed
e8c37c1e2189: Image successfully pushed
68bbfd9543a7: Image successfully pushed
9e20baae42c8: Image already exists
8b74d7a75802: Image successfully pushed
3383909e8f95: Image already exists
e0919a8b95a8: Image already exists
6ad0799af6bd: Image successfully pushed
9213e81cb0f2: Image successfully pushed
607e965985c1: Image successfully pushed
1ff9f26f09fb: Image successfully pushed
9a61b6b1315e: Image already exists
902b87aaaec9: Image successfully pushed
0.1: digest: sha256:a2b1d8a3b283f13e8d6a1407e886ca8ee62d93377949e050b9e05509ce6aaf86 size: 30568
What just have happened??? Why several images have been pushed? Also where they were actually pushed - nothing changed on my private repo on docker hub (screen).
I am not sure If I understand docker hub correctly.
What I want is to build image from Dockerfile and push it to my repo to make it available for a client to pull it on his side and run in container...
You understand correctly.
There is an image for each layer in the image, corresponding to each instruction in a Dockerfile. Docker pushes these layers independently.
As you didn't specify a tag, Docker will push all the tags in the repository (in this case just 0.1). Anyone with access to your repository should be able to download it with docker pull alek/test:0.1. If you look at the tags tab on the Hub, you should see your images there.
If you do a docker push without a tag, I think it pushes the whole repo - i.e. all the images. If you do docker run or docker pull without a tag, it will use the latest tag. So I assume the 0.1 tag got pushed in your case, but you would need to say docker pull alek/test:0.1 to pull it.

Resources