Reputation: 41
Currently I am trying to make my docker container's network stack be the same as my machine's in my docker-compose yml. I saw on the docker docs you can use "hostnet" to use your own network stack. I am using this but I keep getting an error saying... services: xxxxx: xxxxx: networks: hostnet:{}
networks: hostnet: external: true name: host
networks.hostnet value Additional properties are not allowed ('name' was unexpected)
What is wrong, and is there also a way to configure a docker compose file so that my container will have the same Network ID?
Upvotes: 1
Views: 980
Reputation: 263469
This can be achieved using:
network_mode: "host"
in the definition for your service. See Docker's compose file documenting for more details on this: https://docs.docker.com/compose/compose-file/#network_mode
Note that I personally consider this the option of last resort. If you can achieve your goals by publishing a single port instead of disabling the network namespacing features of docker, your solution will be more secure and portable.
Upvotes: 2