equivalent of --net=host in docker compose file when creating docker container
5,726
Use network_mode
instead:
network_mode
Network mode. Use the same values as the docker client
--network
parameter, plus the special formservice:[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
.
Related videos on Youtube
Author by
user13539846
Updated on September 18, 2022Comments
-
user13539846 over 1 year
I tried
docker 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.
-
muru about 3 yearsNote that you say "dockerfile" but this isn't a Dockerfile but a Docker Compose file.
-
user13539846 about 3 yearsYup, that was my bad I got confused. Will change it
-
Noushad about 3 yearscan we do this with a Dockerfile. ?
-
-
user13539846 about 3 yearsOh, thank you sir!
-
Noushad about 3 yearscan we achieve the same using a Dockerfile ?
-
muru about 3 years@Noushad no, there's nothing similar in the Dockerfile instructions. It might be possible by some custom Dockerfile syntax, but I don't know of any.
-
Noushad about 3 years@muru Alright, thanks a lot for the clarification