style: apply global formatting fixes (struct, spacing, zhlint)

This commit is contained in:
Baohua Yang
2026-02-21 11:08:52 -08:00
parent ad68b2d973
commit 79ac9c639a
159 changed files with 1708 additions and 882 deletions

View File

@@ -2,7 +2,7 @@
本节将通过一个简单的 Web 应用例子带你快速体验 Docker 的核心流程构建镜像运行容器
### 1. 准备代码
### 1准备代码
创建一个名为 `hello-docker` 的文件夹并在其中创建一个 `index.html` 文件
@@ -10,7 +10,7 @@
<h1>Hello, Docker!</h1>
```
### 2. 编写 Dockerfile
### 2编写 Dockerfile
在同级目录下创建一个名为 `Dockerfile` (无后缀) 的文件
@@ -19,7 +19,7 @@ FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
```
### 3. 构建镜像
### 3构建镜像
打开终端进入该目录执行构建命令
@@ -27,11 +27,11 @@ COPY index.html /usr/share/nginx/html/index.html
$ docker build -t my-hello-world .
```
* `docker build`: 构建命令
* `-t my-hello-world`: 给镜像起个名字标签
* `.`: 指定上下文路径为当前目录
* `docker build`构建命令
* `-t my-hello-world`给镜像起个名字 (标签)
* `.`指定上下文路径为当前目录
### 4. 运行容器
### 4运行容器
使用刚才构建的镜像启动一个容器
@@ -39,15 +39,15 @@ $ docker build -t my-hello-world .
$ docker run -d -p 8080:80 my-hello-world
```
* `docker run`: 运行命令
* `-d`: 后台运行
* `-p 8080:80`: 将宿主机的 8080 端口映射到容器的 80 端口
* `docker run`运行命令
* `-d`后台运行
* `-p 8080:80`将宿主机的 8080 端口映射到容器的 80 端口
### 5. 访问测试
### 5访问测试
打开浏览器访问 [http://localhost:8080](http://localhost:8080),你应该能看到 "Hello, Docker!"
打开浏览器访问 [http://localhost:8080](http://localhost:8080),你应该能看到 HelloDocker!”
### 6. 清理
### 6清理
停止并删除容器
@@ -65,4 +65,4 @@ $ docker stop <CONTAINER_ID>
$ docker rm <CONTAINER_ID>
```
恭喜你已经完成了第一次 Docker 实战接下来请阅读 [Docker 核心概念](../02_basic_concept/README.md) 做深入了解
恭喜你已经完成了第一次 Docker 实战接下来请阅读 [Docker 核心概念](../02_basic_concept/README.md)做深入了解