What's the differences between layer and image in docker?

Layers are what compose the file system for both Docker images and Docker containers.

It is thanks to layers that when you pull a image, you eventually don't have to download all of its filesystem. If you already have another image that has some of the layers of the image you pull, only the missing layers are actually downloaded.

are these rest layer IDs correspond to some other images?

yes, they are just like images, but without any tag to identify them.

can I view a layer as an image?

yes


show case

docker pull busybox
docker history busybox
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
d7057cb02084        39 hours ago        /bin/sh -c #(nop) CMD ["sh"]                    0 B
cfa753dfea5e        39 hours ago        /bin/sh -c #(nop) ADD file:6cccb5f0a3b3947116   1.096 MB

Now create a new container from layer cfa753dfea5e as if it was an image:

docker run -it cfa753dfea5e sh -c "ls /"
bin   dev   etc   home  proc  root  sys   tmp   usr   var

Tags:

Docker

Image