Difference between Docker Image and Container

1. Docker Image :
The concept of Images and Container is like class and object in which object is instance of class and class is blue print of object. Images are different in Virtual Machines and Docker, in virtual machines images are just snapshots of running virtual machine at different point of times but Docker images are little bit different from them and most important and major difference is that docker images are immutable that is they can not be changed.

In the real-world, it happens a lot that a software works on one computer but it does not works on others due to different environments, this issue is completely solved by docker images and using this, application will work same on everyone’s PC . Every developer on a team will have exact same development instance. Each testing instance is exactly same as development instance. Your production instance is exactly same as testing instance. Also Developers around World can share their Docker Images on a Platform called Docker HUB.

2. Docker Container :
They are actually Docker Virtual Machine but commonly called as Docker Containers . If a Docker image is a map of house, then Docker Container is actual build house or in other words we can call it as instance of image. As per official website, containers are runnable instance of an image. You can create, start, stop, move, or delete a container using Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.

A application runs using a cluster of containers which are self isolated from one another and also from host machine where they are running example if a backend application is running on docker container at port 8000 and you tried to access it from host machine, you will not be able to access as containers are self isolated and in that case you have to explicitly expose your application at a certain port and connect your machine port to that port .

Example –



docker run --publish 8000:8080 --detach --name alias_name application_name:1.0 

Here application running at port 8080 in container is connected to port 8000 at the host machine. Now it can accessed application using URL localhost:8000



Difference between Docker Image and Docker Container :

S.NO Docker Image Docker Container
1 It is Blueprint of the Container. It is instance of the Image.
2 Image is a logical entity. Container is a real world entity.
3 Image is created only once. Containers are created any number of times using image.
4 Images are immutable. Containers changes only if old image is deleted and new is used to build the container.
5 Images does not require computing resource to work. Containers requires computing resources to run as they run as Docker Virtual Machine.
6 To make a docker image, you have to write script in Dockerfile. To make container from image, you have to run “docker build .” command
7 Docker Images are used to package up applications and pre-configured server environments. Containers use server information and file system provided by image in order to operate.
8 Images can be shared on Docker Hub. It makes no sense in sharing a running entity, always docker images are shared.
9 There is no such running state of Docker Image. Containers uses RAM when created and in running state.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.