Docker Images vs Containers : Beyond the thin line

Swastik Mukherjee
3 min readFeb 12, 2022

Docker has been there for a while and it is disrupting the idea of “packing and Shipping” the code to a whole new next level. The complex microservices are now flexible and comfortable with the optimal utilization of the resources of host , being well isolated from each other. You just need to Build the image, ship and run the container, that’s it. But wait, what is image ? what is container ? let’s deep dive into it.

Airflow – SFU Professional Master's Program in Computer Science – Medium
D for Docker and D for Dexter

What is Docker image ?

Docker images are the Immutable (not changeable) Read-only Layered file, i.e. nothing but a blueprint for a container. Sounds heavy ? In easy term, It can be said as the template file that holds the dependencies, libraries, source code, tools and other files needed for running a application. You write the docker images to create/run conatiners from it. In short, the set of instrcution written over a file is the docker image and when that gets into action it is container.

Images vs Containers

What is Docker container ?

As stated earlier, the image in action i.e. the running unit of of softwares can be termed as the containers.In programing terminology, we can say images are the class and conatiners are the object. These are lightweight, portable and encapsulated virtualized runtime for applications. the main difference is conatiners have state.

Conatiner states

Building or Creating docker images

There are two ways of creating or building the images. Either you use pre-existing image from public/private registry or build your own image (Industry practice).

How images look

Every image has its name and tag. You can pull a pre-existing docker image from dockerhub with below command.

$ docker pull image_name

The command extracts the output like below.

Pre-existing image

If you want to create your own image then you have to write your own Dockerfile and build with below command.

$ Docker build .

All the images can be listed with the below command.

$ docker images
Without name and tags

you can inspect the image by following command.

$ docker image inspect image_name/id
All about the image

Whereas you can find the conatiner with the following command.

$ docker ps -a

However, I will create a dedicated thread discussing about docker container. Thank you very much for your time.

--

--