docker_practice/appendix/repo/nginx.md
Kang Huaishuai 18ab3069a3
Update soft to latest version
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
2020-04-26 10:34:02 +08:00

49 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# [Nginx](https://hub.docker.com/_/nginx/)
## 基本信息
[Nginx](https://en.wikipedia.org/wiki/Nginx) 是开源的高效的 Web 服务器实现,支持 HTTP、HTTPS、SMTP、POP3、IMAP 等协议。
该仓库位于 `https://hub.docker.com/_/nginx/` 提供了 Nginx 1.0 ~ 1.18.x 各个版本的镜像
## 使用方法
下面的命令将作为一个静态页面服务器启动
```bash
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
```
用户也可以不使用这种映射方式通过利用 Dockerfile 来直接将静态页面内容放到镜像中内容为
```bash
FROM nginx
COPY static-html-directory /usr/share/nginx/html
```
之后生成新的镜像并启动一个容器
```bash
$ docker build -t some-content-nginx .
$ docker run --name some-nginx -d some-content-nginx
```
开放端口并映射到本地的 `8080` 端口
```bash
$ docker run --name some-nginx -d -p 8080:80 some-content-nginx
```
Nginx的默认配置文件路径为 `/etc/nginx/nginx.conf`可以通过映射它来使用本地的配置文件例如
```bash
$ docker run -d \
--name some-nginx \
-v /some/nginx.conf:/etc/nginx/nginx.conf:ro \
nginx
```
## Dockerfile
请到 https://github.com/docker-library/docs/tree/master/nginx 查看。