Docker compose指定容器网络作为主机网络



运行docker容器的网络===主机网络是什么?

docker run --rm -d --network host --name my_nginx nginx

基本上,如何在docker中指定--network host-compose

目前,我通过指定从主机到docker容器的端口映射来运行此操作,其中我在两个

上使用相同的端口,

version: '3.8'
services:
api-server:
build: '.'
ports:
- "8080:8080"

您需要在docker-compose.yml中指定您的服务中的网络模式。像这样添加:

version: '3.8'
services:
network_mode: "host"
api-server:
build: '.'

最新更新