Docker has been a game changer in software development as it has enabled developers to share an isolated environment that lets the whole team (or group of users) build, test and deploy applications in a very consistent and intuitive way.
Since the technology has been around for a -relatively- long time I am pretty sure you’ve already come across terms such as image, container, volumes or even Dockerfile. Docker images and containers are two of the most fundamental concepts of this particular technology, and many new comers to Docker struggle to clearly distinguish the two.
In the following sections we will be discussing about what Docker images and containers are as well as their main differences.
Docker Image (Container Image)
A docker image, is an immutable file containing multiple layers each of which corresponds to a filesystem that can contain dependencies, scripts or other configuration.
This layering increases reusability and speeds up image builds since every step can be cached. Now the next build will load a step from the cache unless it has been modified since the last build.
Now docker build command is used to build an image from a Dockerfile – a text file consisting of commands a user could call on the command line to create a desired image.
Docker images are the basis of containers. An image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime. An image typically contains a union of layered filesystems stacked on top of each other.
Images are stored in a Docker Registry – the default one is Docker Hub but you can even host your own Docker Registry that can only be accessed by your organisation.
You can view all the images on the host machine by running
$ docker images
Docker Container
Now a Docker Container is an instance of a docker image, running on a completely isolated environment (i.e. is isolated from any other process running on the machine) and can be executed on any Operating System (portability!).
Containers are lightweight and portable run-time environments in which users can run applications in isolation from the underlying host machine.
A running container can be stopped but at the same time it can retain the settings and any filesystem changes so that they can be re-used the next time it gets restarted.
A container is a runtime instance of a docker image.
A Docker container consists of
- A docker image
- An execution environment
- A standard set of instructions
The concept is borrowed from shipping containers, which define a standard to ship goods globally. Docker defines a standard to ship software.
You can view all running containers by running
$ docker ps
If you want to also list containers that are not up and running you’d have to pass the -a option:
$ docker ps -a
Final Thoughts
Docker provides a platform for developers to develop, run, and ship applications. Understanding how to effectively use Docker is definitely something that’s going to help throughout your software development journey and career.
Therefore, it’s important to first understand the basic principles and components of the technology that will then help you use Docker more comfortably. And this journey starts with you being able to distinguish a Docker Image and a Docker Container.
In a nutshell the Docker Image is a construct consisting of multiple layers, as specified in Dockerfile while the Docker Container is an (running) instance of a Docker Image (and perhaps the reason why you may want to use Docker!).
Become a member and read every story on Medium. Your membership fee directly supports me and other writers you read. You’ll also get full access to every story on Medium.
Related articles you may also like







