无效的顶级属性";网络“U模式”;来自docker compose

无效的顶级属性";网络“U模式”;来自docker compose,docker,docker-compose,Docker,Docker Compose,我想在docker compose上使用网络模式:“主机”,但被拒绝 $ cat docker-compose.yml version: "3.7" services: hello: image: hello-world:latest $ docker-compose up Creating network "tmp_default" with the default driver Creating tmp_hello_1 ... done Attaching to tmp_hell

我想在docker compose上使用网络模式:“主机”,但被拒绝

$ cat docker-compose.yml
version: "3.7"
services:
  hello:
    image: hello-world:latest
$ docker-compose up
Creating network "tmp_default" with the default driver
Creating tmp_hello_1 ... done
Attaching to tmp_hello_1
hello_1  |
hello_1  | Hello from Docker!
hello_1  | This message shows that your installation appears to be working correctly.
:
tmp_hello_1 exited with code 0
嗯。让我使用网络模式:“主机”

为什么!?这是官方的,不是吗?


网络模式不是顶级属性。写在服务下

version: "3.7"
services:
  hello:
    network_mode: "host"
    image: hello-world:latest
$ docker-compose -v
docker-compose version 1.24.1, build 4667896b
$ docker -v
Docker version 19.03.2, build 6a30dfca03
$  cat /etc/os-release
NAME="Ubuntu"
VERSION="19.04 (Disco Dingo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.04"
VERSION_ID="19.04"
version: "3.7"
services:
  hello:
    network_mode: "host"
    image: hello-world:latest