What is the difference between Docker Images, Containers and Registries ?
This tutorial explains you the difference between docker images, containers and registry. You will also learn about main docker objects, how docker works and the anatomy of the container in this tutorial.
Difference between Docker images, containers and registry
The following diagram depicts the docker architecture. Let’s learn about various docker objects like images, containers, Dockerfile, Registry and its concepts in brief.
Images
We can say images are like templates for containers. They consist mostly of a file system and also metadata about containers on how it should operate by default. If you wanted to move or share a container, you can do so by making an image and sharing the images using docker commands.
Docker Host
Docker manages images on a host and gives you the tool to transport them across hosts usually via Registries.
Containers
Containers are instances of images, basically copies, then it has isolated process inside them. You can change the file system, but any changes that you have done in the container file system should be committed back to an image in order to persist the changes made.
Docker manages containers like processes, meaning you can start, stop, run in the background, run interactively etc.,
Dockerfile
Dockerfiles are build files, that instructs docker on how to consistently build and configure the container images.
Registry
Registries serve images, you can pull from and push into docker. The main public registry docker.io is called as docker hub/ docker index.
Why Docker Container is more efficient ?
When you start a container, it is always based on the image, however the image file system is not actually copied. Docker containers uses Layered, Copy-on-write FileSystem, which means the files that you see in container while starts are actually the files in the image file system until the change is made.
Whenever changes are made in the container, it collectively make up a layer and this can be committed back to an image. Images are just a collection of layers over the file system changes. This is the reason why docker is efficient in terms of disk space and also why Registry is so important, since they are aware of layers and can only send the layers that you don’t have when you pull an image.
Docker Containers Vs Linux Containers
Containers are not just a file system, they always run with a command and this command run processes in isolation. This is classically known as linux containerization O-LXC (OS-level LinuX Containers) which is where the container originally comes from. However Docker containers are much more than linux containers and some call them as application containers but we can say Docker container is a Higher-Level Container.
We can say, Linux containers focus on process isolation and docker containers is built on this and provide a high level tooling for a more portable higher level containers.
Also See:
- Docker images are storage location ?
- What is the difference between Containers and VMs ?
- How to add new user to the Docker container using Dockerfile?
- Event Driven Microservices: Spring Boot + Kubernetes + Docker + Helm + Google Cloud
- Check docker image contents after you pull a docker image