doc: Update dockerfile.md #120

This commit is contained in:
jaywcjlove 2022-11-17 23:37:33 +08:00
parent c6ac6dcf11
commit 61c3a6e528

View File

@ -207,8 +207,31 @@ temp?
`EXPOSE <port> [<port>/<protocol>...]` | 运行时侦听指定的网络端口 `EXPOSE <port> [<port>/<protocol>...]` | 运行时侦听指定的网络端口
<!--rehype:class=auto-wrap--> <!--rehype:class=auto-wrap-->
Dockerfile 示例
----
<!--rehype:body-class=cols-2-->
### 服务静态网站的最小 Docker 镜像
```dockerfile
FROM lipanski/docker-static-website:latest
# 使用 .dockerignore 文件来控制图像中的内容!
# 复制当前目录内容,到容器中
COPY ./ .
```
这会产生一个 **`154KB +`** 的单层镜像。 如果您需要以不同的方式配置 `httpd`,您可以覆盖 CMD 行:
```dockerfile
FROM lipanski/docker-static-website:latest
COPY . .
CMD ["/busybox","httpd","-f","-v","-p","3000","-c","httpd.conf"]
```
缩小镜像过程[查看原文](https://lipanski.com/posts/smallest-docker-image-static-website),镜像 [Dockerfile 源码](https://github.com/lipanski/docker-static-website)。
### Docker 镜像多阶段构建 ### Docker 镜像多阶段构建
<!--rehype:wrap-class=col-span-2-->
```dockerfile ```dockerfile
FROM golang:alpine as builder FROM golang:alpine as builder