DEV Community

Cover image for Docker: Images Vs Containers
Rakib Hasan
Rakib Hasan

Posted on

Docker: Images Vs Containers

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

  1. 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.
  2. State: Images are static, Once created, they do not change.
  3. Creation: Images are built from a set of instructions (e.g., a Dockerfile). They are created using the docker build command.
  4. Storage: Images are stored in image registries (e.g., Docker hub, Amazon ECR. Google Container Registry).
  5. Usage: Images serve as the blueprint for a containers. They are used to create containers but cannot be executed directly.

Containers

  1. Definition: A container is a runnable instance of an image. Containers include the application and all its dependencies, running in an isolated environment.
  2. State: Containers are dynamic. They can be started, stopped, moved, and deleted. Their state can change over time as the application runs.
  3. Creation: Containers are created from images using the docker run command.
  4. 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).
  5. 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.

docker-images-vs-containers

Top comments (0)