I have a docker container and I want to give it --network=host
AND --network=postgres
.
I need to connect to the host network in order to use the host datadog server (UDP) and the postgres
network for its database.
Trying to add both network results in docker: conflicting options: cannot attach both user-defined and non-user-defined network-modes.
.
Any idea what's the correct way to handle this?
CodePudding user response:
You could use the the IP address of the host machine from within you container in order to send requests to the host machine.
A better solution, however, would be to use --add-host=host.docker.internal:host-gateway
or
extra_hosts:
- host.docker.internal:host-gateway
where host.docker.internal
is then the host name of the host network inside your docker container. This name can of course be changed to your liking.