Images
We have seen very basic stuff of docker images, now we will do a deep dive into docker images. Images are built and distributed like software. As we have seen in the Continuous Integration chapter that there should be a process of Build & Release a software, we must do the same if we are releasing Images. We have mentioned earlier Images are stopped state of a container so you can stop a container and create a new image from it.Pulling Images
Image Registries
Docker images are stored in image registries. The most common image registry is Docker Hub. Other registries exist including 3rd party registries and secure on-premises registries, but Docker Hub is the default, and it’s the one we’ll use in this tutorial.https://hub.docker.com/
Image registries contain multiple image repositories. Image repositories contain images. That might be a bit confusing, so Figure 5.2 shows a picture of an image registry containing 3 repositories, and each repository contains a few images.
Image Tags
While pulling an image we give the image name: TAG and docker will reach by default to docker hub registry and find the image with the TAG we specified.
Docker hub contains Official and unofficial repositories.
Official repositories are from Docker, Inc. These are safe and secure images with the latest up to date software.
Unofficial repositories are uploaded by anyone and are not verified by Docker, Inc. The list below contains a few of the official repositories and shows their URLs that exist at the top level of the Docker Hub namespace:
• nginx - https://hub.docker.com/_/nginx/
• busybox - https://hub.docker.com/_/busybox/
• redis - https://hub.docker.com/_/redis/
• mongo - https://hub.docker.com/_/mongo/
Our personal images live in the unofficial repositories. Below are some examples of images in my repositories:
visualpath/myjsonsinatra - https://hub.docker.com/r/visualpath/myjsonsinatra/
visualpath/devops-docker-ci - https://hub.docker.com/r/visualpath/devops-docker-ci/
Image Tags
While pulling an image we give the image name: TAG and docker will reach by default to docker hub registry and find the image with the TAG we specified.
docker pull nginx: latest
if we do not specify any tag then the default tag is latest. The latest tag does not mean that the images are latest in version, it’s just the name of the tag and that’s all.
docker pull nginx
Images and layers
All Docker images are made up of one or more read-only layers as shown below
There are a few ways to see and inspect the layers that make up an image, and we’ve already seen one of them. Let’s take a second look at the output of the docker pull node:latest command from earlier:
$ docker pull node
Each line in the output above that ends with “Pull complete” represents a layer in the image that was pulled. As we can see, this image has 5 layers.
Using default tag: latest
latest: Pulling from library/node
ef0380f84d05: Pull complete
24c170465c65: Pull complete
4f38f9d5c3c0: Pull complete
4125326b53d8: Pull complete
a1468c06f443: Pull complete
cb113e1791ca: Pull complete
519ce9303f95: Pull complete
f15f31d0549a: Pull complete
Digest: sha256:1d496e5c8e692dfabeb1cc8a18f01e2b501111f32c3d08e94e5402daeceb94e6
Each layer is only a set of differences from the layer before it. The layers are stacked on top of each other. When you create a new container, you add a new writable layer on top of the underlying layers. This layer is often called the “container layer”. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this thin writable container layer. The diagram below shows a container based on the Ubuntu 15.04 image.
Comments
Post a Comment