note/tech/docker.md
2025-11-19 10:16:05 +08:00

18 lines
325 B
Markdown

# docker 使用技巧
## docker 与主机通讯
> 可使用以下两种方法设置。
1. docker run --add-host=host.docker.internal:host-gateway
2. docker compose file 中添加 `extra_hosts` 选项
```yaml
version: '3'
services:
web:
image: nginx
extra_hosts:
- "host.docker.internal:host-gateway"
```