Skip to content
Related Articles

Related Articles

Difference between Docker Image and Container

View Discussion
Improve Article
Save Article
  • Last Updated : 12 Jul, 2022

1. Docker Image: The concept of Images and Container is like class and object in which object is an instance of class and class is the blueprint of the object. Images are different in Virtual Machines and Docker, in virtual machines images, are just snapshots of running virtual machines at different points of time but Docker images are a little bit different from them, and the 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 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, the application will work same on everyone’s PC. Every developer on a team will have exact same development instance. Each testing instance is exactly the same as the development instance. Your production instance is exactly the same as the 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 Machines but are commonly called Docker Containers. If a Docker image is a map of the house, then Docker Container is actual build house or in other words, we can call it an instance of an image. As per the 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. An 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 a 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 access application using URL localhost:8000

Difference between Docker Image and Docker Container:

Docker ImageDocker Container
It is Blueprint of the Container.It is instance of the Image.
Image is a logical entity.Container is a real world entity.
Image is created only once.Containers are created any number of times using image.
Images are immutable.Containers changes only if old image is deleted and new is used to build the container.
Images does not require computing resource to work.Containers requires computing resources to run as they run as Docker Virtual Machine.
To make a docker image, you have to write script in Dockerfile.To make container from image, you have to run “docker run IMAGE” command
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.
Images can be shared on Docker Hub.It makes no sense in sharing a running entity, always docker images are shared.
There is no such running state of Docker Image.Containers uses RAM when created and in running state.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!