equivalent of --net=host in docker compose file when creating docker container

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:

networks: name: host

and

networks: 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.

3

1 Answer

Use network_mode instead:

network_mode

Network mode. Use the same values as the docker client --networkparameter, 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.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like