Table of contents
If you are new to learning and working with Docker, you might be wondering how Docker images differ from Docker containers. Without further ado, let's dive into it.
Both Images and Containers are two distinct concepts in the Docker ecosystem and we need them both in order to work with Docker.
Docker Containers
Docker containers are small packages that contain our application and the environment required to run it (system tools, libraries, settings, etc). We can think of containers as running/executable units of software, the units we run locally, on servers and cloud providers in order to start our application.
Docker Images
Docker images are read-only templates of Docker containers. In order to create a Docker Container, we need a template or blueprint which is a Docker Image. Therefore, containers are dependent on images and use them to construct a run-time environment and run an application.
Docker images are typically built using a Dockerfile, which is a script that specifies the instructions for building the image. Docker images are stored in a registry and can be shared and reused by other users.
We can run multiple containers from the same image as shown below.
It is also worth mentioning that we can create Docker images based on other Docker images and this is often referred to as "layering" Docker images. The newly created Docker image inherits all the files and settings from the parent image, and we can add new files, dependencies, and configurations as needed.
Summary
A Docker image is a read-only template or snapshot of a Docker container.
A Docker container is a runnable instance of a Docker image.
Images contain applications code, meanwhile, containers run it.
We can use one image to create multiple containers on different servers.
I hope you found this information helpful, stay tuned for more content! :)