I trieddocker run --net=host -d --name pdns-recursor pschiffe/pdns-recursor and it works. Now my goal is to use dockerfile to pass some environment without errors.

I tried:

  name: host


  name: "host"

and also the examples indicated here.

I always get an The Compose file './docker-compose.yml' is invalid because: services.recursor.networks.name contains an invalid type, it should be an object, or a null.

Any suggestions are much appreciated.

  • Note that you say "dockerfile" but this isn't a Dockerfile but a Docker Compose file. – muru Mar 1 at 7:38
  • Yup, that was my bad I got confused. Will change it – user13539846 Mar 1 at 8:39

Use network_mode instead:


Network mode. Use the same values as the docker client --network parameter, plus the special form service:[service name].

network_mode: "bridge"
network_mode: "host"
network_mode: "none"

You can use networks to specify host networking in swarm mode, by setting the driver of a given network to host.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.