Docker is a containerization platform that allows developers to package applications with all their dependencies into a standardized unit — called a container — to ensure that the application works consistently across different environments.
- A container includes everything needed to run: code, libraries, environment variables, etc.
- Ensures “it works on my machine” also works in production.
- Multiple containers can run on the same server without interfering with each other.
- Each container is lightweight and isolated from others.
- Applications in containers can be deployed across multiple servers or nodes.
- Great for cloud environments and horizontal scaling.
Docker CLI <----> Docker REST API <----> Docker Daemon (dockerd)
- Docker Daemon: Core engine that manages containers, images, and networks.
- Docker REST API: Interface for communicating between CLI or other tools and the daemon.
- Docker CLI: Command-line interface to interact with Docker.
A Docker image is a snapshot that contains everything needed to run a container:
- Base Image: Starting point (e.g.,
ubuntu,python,node) - Application Code: Your own app files
- Dependencies: Libraries, environment config, etc.
- Metadata: Ports, volume info, author, etc.
- Creation – Define image in a
Dockerfile. - Build – Generate image using
docker build. - Storage – Save locally or in a registry.
- Distribution – Share via Docker Registry.
- Execution – Run image as a container.
A Dockerfile is a script of instructions to build a Docker image, layer by layer.
Each command (like FROM, COPY, RUN, CMD) adds a new layer to the image.
A Docker container is a running instance of a Docker image:
- It uses the image as a blueprint.
- It runs in isolation in the host OS kernel.
- You can start, stop, remove, and restart containers.
A service for storing and distributing Docker images.
- Tags: Labels that identify versions of an image.
- Repositories: Collections of related Docker images.
- Public: Docker Hub (most widely used)
- Private: Internal registries (e.g., for companies)
- Third-Party: Amazon ECR, GitHub Container Registry, etc.
- Version Control
- Collaboration
- Security
- Access Control
graph LR
A[Dockerfile] --> B[Build Image]
B --> C[Run Container]
C --> D[Push to Registry]
D --> E[Image Available]
E --> F[Pull by Others]
F --> G[Run Container]
- Write
Dockerfile - Build → Docker Image
- Run → Docker Container
- If stable, push to Registry (e.g., Docker Hub)
- Others can pull and run
Docker Desktop includes:
-
Docker Engine:
- Daemon (
dockerd) - CLI
- REST API
- Daemon (
-
GUI:
- View and manage images, containers, volumes, and networks.
- Internally calls Docker API.
- Microservices Architecture – Each service runs in its own container.
- CI/CD Pipelines – Consistent build/test environments.
- Cloud Migration – Move apps between clouds without reconfiguring.
- Scalable Web Applications – Load-balance containers across nodes.
- Testing and QA – Spin up disposable environments quickly.
- Machine Learning / AI – Package Jupyter notebooks, models, and dependencies.
- API Development & Deployment – Wrap APIs with consistent runtime environments.