Docker: Images Vs Containers
Rakib Hasan
Posted on July 14, 2024
In technologies like Docker, Images and Containers are fundamental concepts in containerization. People how are new to this technology often get confused about different between Images and Containers. Hope fully you will learn key difference between them in the blog post.
Images
- Definition: An image is lightweight, standalone, and executable package that include everything needed to run a piece of software, including code, runtime, libraries, environment variables, and configuration files.
- State: Images are static, Once created, they do not change.
-
Creation: Images are built from a set of instructions (e.g., a Dockerfile). They are created using the
docker build
command. - Storage: Images are stored in image registries (e.g., Docker hub, Amazon ECR. Google Container Registry).
- Usage: Images serve as the blueprint for a containers. They are used to create containers but cannot be executed directly.
Containers
- Definition: A container is a runnable instance of an image. Containers include the application and all its dependencies, running in an isolated environment.
- State: Containers are dynamic. They can be started, stopped, moved, and deleted. Their state can change over time as the application runs.
-
Creation: Containers are created from images using the
docker run
command. - Storage: Containers are temporary by nature. Their data can be lost if they are not configured to persist (e.g., using volumes for data persistence).
- Usage: Containers are the actual instances where applications run. They provide the runtime environment for applications and can be managed (e.g., started, stopped) using Docker commands.
Summary
- Images are immutable templates that define what the containerized application looks like, including all dependencies and configurations.
- Containers are the live, running instances of those images, providing the execution environment for applications.
💖 💪 🙅 🚩
Rakib Hasan
Posted on July 14, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.