diff --git a/docs/dockerfile.md b/docs/dockerfile.md index a7576db..9e64c75 100644 --- a/docs/dockerfile.md +++ b/docs/dockerfile.md @@ -207,8 +207,31 @@ temp? `EXPOSE [/...]` | 运行时侦听指定的网络端口 +Dockerfile 示例 +---- + + +### 服务静态网站的最小 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 镜像多阶段构建 - ```dockerfile FROM golang:alpine as builder