As we have seen, Docker images and Docker containers are closely related. So, how do the two concepts differ?
First of all, a Docker image is inert. It takes up some storage space but does not use any system resources. In addition, a Docker image cannot be changed after creation and as such is a “read-only” medium. As a side note, it is possible to add changes to an existing Docker image, but this will create new images. An original, unmodified version of the image will remain.
As we already mentioned, a Docker image can be used to create an unlimited number of similar containers. How exactly is a Docker container different from a Docker image? A Docker container is a running instance (i.e. an instance in the process of execution) of a Docker image. Like any software executed on a computer, a running Docker container uses the system resources, working memory and CPU cycles. Furthermore, the status of a container changes over its lifecycle.
If this description seems too abstract, use this example from your day-to-day life to help: Think of a Docker image like a DVD. The DVD itself is inert – it sits in its case and does nothing. It permanently occupies the same limited space in the room. The content only becomes “alive” when the DVD is played in a special environment (DVD player).
Like the film generated when a DVD is played, a running Docker container has a status. In the case of a film, this includes the current playback time, selected language, subtitles, etc. This status changes over time, and a playing film constantly consumes electricity. Just like how an unlimited number of similar containers can be created from a Docker image, the film on a DVD can be played over and over again. What’s more, the running film can be stopped and started, as can a Docker container.