MikeJ
MikeJ

Reputation: 2437

Docker container DNS - Resolve URL

I have a docker container that needs to access an network server on the LAN. This server is visible from the docker host machine and I can access it from within the container when I reference the IP address directly.

However I need to be able to specify a url and port (e.g http://myserver:8080) rather than an IP address, which the docker container cannot resolve.

How can I configure the container to resolve this? ideally using the docker hosts dns. I have looked at many of the docs, but not being a DNS expert, it doesn't seem straightforward.

UPDATE: I have tried this, which seems to work, but does this have any downsides or unintended consequences?

--network host

Thanks,

Upvotes: 1

Views: 2221

Answers (1)

yamenk
yamenk

Reputation: 51738

The rigth way to do this is to configure the docker daemon dns as specified under daemon-dns-options.

Using the host network is not recommended as it has some downsides https://docs.docker.com/network/host/

Upvotes: 1

Related Questions