# 第五章 操作容器

容器是 Docker 又一核心概念。

简单的说，容器是独立运行的一个或一组应用，以及它们的运行态环境。对应的，虚拟机可以理解为模拟运行的一整套操作系统 (提供了运行态环境和其他系统环境) 和跑在上面的应用。

本章将具体介绍如何来管理一个容器，包括创建、启动和停止等。

## 版本号说明

本章示例涉及多个 Docker 镜像，遵循以下版本号最佳实践：

* **官方镜像**（如 `ubuntu`、`nginx`、`mysql`）：使用具体大版本号（如 `ubuntu:24.04`、`mysql:8.4`）而非 `latest`，确保示例的可重复性
* **镜像标签约定**：
  * `latest` 或 `v1.0.0` 等：带标签的自定义镜像，示例中指定具体版本
  * `24.04`、`8.4`：官方镜像的稳定版本分支
  * 生产环境建议：指定���确版本号（如 `nginx:1.30.0`、`mysql:8.4.4`）而非仅大版本号
* [启动容器](/docker_practice/di-yi-bu-fen-ru-men-pian/05_container/5.1_run.md)
* [守护态运行](/docker_practice/di-yi-bu-fen-ru-men-pian/05_container/5.2_daemon.md)
* [终止容器](/docker_practice/di-yi-bu-fen-ru-men-pian/05_container/5.3_stop.md)
* [进入容器](/docker_practice/di-yi-bu-fen-ru-men-pian/05_container/5.4_attach_exec.md)
* [导出和导入容器](/docker_practice/di-yi-bu-fen-ru-men-pian/05_container/5.5_import_export.md)
* [删除容器](/docker_practice/di-yi-bu-fen-ru-men-pian/05_container/5.6_rm.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/docker_practice/di-yi-bu-fen-ru-men-pian/05_container.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
