This is the multi-page printable view of this section. Click here to print.
Docker Cheat Sheet
1 - Docker Cheat Sheet
Docker Cheat Sheet
Các lệnh cơ bản
Quản lý Images
Cài đặt Docker
Ubuntu
2 - Docker Architecture
Docker uses a client-server architecture with several key components working together to build, run, and distribute containerized applications.
Architecture Overview
flowchart TD
Client[Docker CLI] -->|commands| Daemon[Docker Daemon]
Daemon -->|manages| Images[Images]
Daemon -->|manages| Containers[Containers]
Daemon -->|manages| Networks[Networks]
Daemon -->|manages| Volumes[Volumes]
Images -->|create| Containers
Registry[Registry] <-->|push/pull| Images
style Client fill:#f9d77e,stroke:#333,stroke-width:2px
style Daemon fill:#78a9ff,stroke:#333,stroke-width:2px
style Images fill:#ffe6cc,stroke:#333,stroke-width:2px
style Containers fill:#d5e8d4,stroke:#333,stroke-width:2px
style Networks fill:#e1d5e7,stroke:#333,stroke-width:2px
style Volumes fill:#fff2cc,stroke:#333,stroke-width:2px
style Registry fill:#f8cecc,stroke:#333,stroke-width:2pxThis simplified overview shows the core components of Docker’s architecture:
- Docker CLI: The command-line interface users interact with
- Docker Daemon: The background service managing all Docker objects
- Images: Read-only templates used to create containers
- Containers: Running instances of Docker images
- Networks: Allow containers to communicate with each other
- Volumes: Persistent data storage for containers
- Registry: Stores and distributes Docker images
Architecture Diagram
graph TD
subgraph "Docker Host"
A[Docker Daemon] --- B[Container Runtime]
A --- C[Images]
A --- D[Volumes]
A --- E[Networks]
B --- F[Container 1]
B --- G[Container 2]
B --- H[Container 3]
F --- I[App Process]
G --- J[App Process]
H --- K[App Process]
end
L[Docker Client] --- A
A --- M[Registry]
classDef container fill:#66aa66,stroke:#333,stroke-width:2px;
classDef daemon fill:#4477aa,stroke:#333,stroke-width:2px;
classDef client fill:#aa6644,stroke:#333,stroke-width:2px;
classDef registry fill:#aa66aa,stroke:#333,stroke-width:2px;
class A daemon;
class F,G,H container;
class L client;
class M registry;Key Components
Docker Client
The Docker client (docker) is the primary way users interact with Docker. When you use commands like docker run, the client sends these commands to the Docker daemon, which carries them out.
Docker Daemon
The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.
Container Runtime
The container runtime is the component that actually runs containers. Docker uses containerd as its container runtime, which handles lower-level container execution.
Images
A Docker image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization.
Containers
A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI.
Docker Registry
A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can also run your own private registry.
Volumes and Networks
Docker provides persistent data storage through volumes and networking capabilities through network drivers.