What is a Docker Image?
Let us understand what a docker image is.
What is a Docker Image?
A Docker image is an immutable file that contains all the libraries, source code, and other scripting files which are needed to run an application. An image is nothing but a collection of layers that packs all the necessary tools like dependencies, configuration, etc which in turn provides a fully functional container environment. The bottom-most layers mostly will be a Linux-based image and the topmost layer will be the application layer (The image which we want to use).
These images are stored in a Docker registry like Docker Hub. For example, in the below image we have a node image that has been downloaded from the Docker hub.
Here we can see that the ‘node’ image is downloaded with all the layers (0bc3020do5f1, a110e5871660, 83d3c0fa203a, etc) that are necessary for the node container to run. These layers of images are read-only files. If we don't specify anything after ‘node’ we get the latest node version. We can also specify specific versions. For eg., docker pull node:16.4.2-alpine3.11. To view all the image details in our system we can use the docker images command.
We can see that the image contains some attributes like:
- TAG — It indicates the version of the image.
- IMAGE ID — This is the unique id given for every image. We use an image id to delete a specific image.
- CREATED — The period of time since it was created.
- SIZE — indicates virtual image’s size.
Key Takeaways:
- Images are read-only files.
- Images are collections of layers that contain all the required test scripts, source code libraries that are necessary for an application to run virtually.
- Images are stored on a Docker registry like Docker hub or on a local registry.
- Use the docker pull command to get an image from the docker hub.
- Docker images can be moved easily from one team to another team.
Read difference between Docker and Virtual Machine to know more about docker.
Conclusion:
Image is a read-only file that can be pulled from the docker hub. Images can be moved from one team to another team. After reading this article, you should now have a good understanding of what a Docker image is. Now that you know what a docker image is read about the Docker container to understand more about it.
Related article: