# 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" ```