Skip to content

Commit

Permalink
doc: Update docker.md dockerfile cheatsheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 1, 2022
1 parent 274c96f commit df6d94b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,10 @@ $ docker volume ls

```shell
$ docker volume prune
```
```

另见
----

- [Dockerfile 备忘清单](./dockerfile.md) _(github.io)_
- [Docker 官方入门教程](https://docs.docker.com/get-started/) _(docker.com)_
25 changes: 24 additions & 1 deletion docs/dockerfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,28 @@ LABEL multi.label1="value1" \
`ENV <key>=<value> ...` | 设置环境变量
`EXPOSE <port> [<port>/<protocol>...]` | 运行时侦听指定的网络端口

### 服务静态网站的最小 Docker 镜像
<!--rehype:wrap-class=col-span-3-->

```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)

## 也可以看看
- [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) _(docker.com)_

- [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) _(docker.com)_
- [Docker 备忘清单](./docker.md) _(github.io)_

0 comments on commit df6d94b

Please sign in to comment.