这个问题很简单,我在执行--net=host时如何传递docker-compose
eclipse:
build:
context: .
dockerfile: eclipse-dockerfile
image: eclipse-docker:latest
volumes:
- "$HOME/.Xauthority:/root/.Xauthority:rw"
networks:
- "host"
environment:
- DISPLAY=$DISPLAY显然不起作用
发布于 2020-08-13 07:17:00
您可以使用network_mode: "host"
在这篇文章中,主机网络驱动程序只在Linux主机上工作,在Docker Desktop for Mac,Docker Desktop for Windows,以及Docker EE for Windows Server上不支持。
下面是一个简单的演示:
docker-compose.yml
version: '3'
services:
web-svc-in-host-net:
image: nginx
network_mode: "host"组成:
docker-compose up -d在localhost上访问nginx (默认情况下,nginx映像在端口80上侦听-因此不需要在curl示例中指定端口):
curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
[...]
</body>
</html>https://stackoverflow.com/questions/63389558
复制相似问题