When using Docker, we start with a base image. We boot it up, create changes and those changes are saved in layers forming another image.
So eventually I have an image for my PostgreSQL instance and an image for my web application, changes to which keep on being persisted.
What is a container?
Answer
A container in Docker is a runnable instance of a Docker image. It's a lightweight and portable environment that encapsulates the application and all its dependencies, ensuring consistency and isolation across different environments.
When you run a Docker image, it creates a container from that image. This container includes the application code, runtime, system tools, libraries, and other dependencies specified in the image. The container runs as an isolated process on the host machine, but it shares the same kernel as the host operating system, making it lightweight and efficient.
Containers allow developers to package their applications and all required dependencies into a single unit, making it easy to deploy and run the application consistently across different environments, such as development, testing, and production. Containers are also portable, meaning they can run on any system that supports Docker, regardless of the underlying infrastructure.
In summary, a Docker container is a lightweight, isolated, and portable runtime environment that encapsulates an application and its dependencies, providing consistency and efficiency in software deployment and management.