mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-26 11:45:33 +00:00
Add blank lines before headers
This commit is contained in:
@@ -30,6 +30,7 @@ Docker 提供了多种方式来指定端口映射。
|
||||
使用 `-p <宿主机端口>:<容器端口>` 格式:
|
||||
|
||||
```bash
|
||||
|
||||
## 将宿主机的 8080 端口映射到容器的 80 端口
|
||||
|
||||
$ docker run -d -p 8080:80 nginx
|
||||
@@ -103,6 +104,7 @@ abc123456 nginx 0.0.0.0:8080->80/tcp web
|
||||
如果不希望对外暴露 (例如数据库服务),应绑定到 `127.0.0.1`:
|
||||
|
||||
```bash
|
||||
|
||||
## 仅允许本机访问
|
||||
|
||||
$ docker run -d -p 127.0.0.1:3306:3306 mysql
|
||||
@@ -134,6 +136,7 @@ Docker 使用 `docker-proxy` 进程 (用户态) 或 `iptables` DNAT 规则 (内
|
||||
当流量到达宿主机端口时,iptables 规则将其目标地址修改为容器 IP 并转发:
|
||||
|
||||
```bash
|
||||
|
||||
## 简化的 iptables 逻辑
|
||||
|
||||
iptables -t nat -A DOCKER -p tcp --dport 8080 -j DNAT --to-destination 172.17.0.2:80
|
||||
|
||||
Reference in New Issue
Block a user