| 短语法 | "8080:80" / "127.0.0.1:8080:80" / "53:53/udp" |
|---|---|
| 长语法 | target / published / protocol / host_ip |
| 默认 | 监听 0.0.0.0 |
示例
示例
services:
web:
image: nginx:1.27-alpine
ports:
- "8080:80"
- "127.0.0.1:9000:9000"
- target: 53
published: "53"
protocol: udp短语法含冒号的值建议加引号,避免 YAML 把 8080:80 解析成六十进制数字(旧版 YAML 陷阱)。