2

I'm looking for a way to access containers that are running on server in our company lan by domain names. By far I only managed to access them by IPs

So the setup is. Docker (for windows) is running on server srv1.ourdomain.com (Windows Server 2019), network for container is configured with l2bridge driver, container's dns name, as specifiedn in run command, is cont1. It is accessible by dns name on the docker host (srv1) and by IP from my machine.

What can I do to access the container by dns name cont1.ourdomain.com from my local machine located in the same lan?

I tried to use proxy (traefik) but it cant rewrite urls in the content, so web applications running inside the container are failing. Bacause of this I can't host multiple web application behind that proxy.

I know that it is possible to map container's port to host port and then it will be accessible from lan through the host name and host port, but applications I'm running are requiring many ports to be mapped (like 8 ports for each container) and with those containers being short-lived developer's environments it will be a hell to find a port pool when running new container.

So again if I can access container and its' ports by IP, is there a way to do the same by DNS name?


UPD1. Container host is a virtual server running on vmware. I tried to follow those recommendations and configure promiscuous mode. Thise doesn't help with dns though.

UPD2. I tried transparent network as well. For some reason DHCP can never assign propper IP and container ends up with autoconfigured ip from 168.x.x.x subnet.

Mak Sim
  • 2,148
  • 19
  • 30

1 Answers1

1

You could create a transparent network and make the container discoverable on the network just like host. However, using host ports is what's recommended.

Did you try PathStrip or PathPrefixStrip with Traefik? That should let you rewrite the URLs for the backend.

Faheem
  • 3,429
  • 19
  • 26
  • Transparens network doesn't seem too much different from the l2bridge. The only difference i see is that it requires mac spoofing and bridge will do mac translation automatically. Are you sure that transparent network will work with DNS in a different way than l2bridge? – Mak Sim Sep 04 '20 at 08:45
  • Yes I tried both PathStrip or PathPrefixStrip. It doesn't work for apps that I'm going to host inside the containers. Traefik rewriting url only in the request's url but not in the response body. So all hrefs to css and scripts will still try to load from the root `domain.com/` even if traefic is operatin on path like `domain.com/deeper/path/`. – Mak Sim Sep 04 '20 at 08:48
  • No reverse proxy will change the content or response body. You have to update your applications to use relative paths for assets. For example drop the `/` from `/deeper/path` and use `deeper/path` without host name or root path. – Faheem Sep 04 '20 at 12:35
  • I can't change the applications, they are provided to me as is. They are indeed root related and they should be like this for assets because applications itself using paths for other purposes, like switching language of interface (`domain.com/en-eu/app`). In that case scripts and css should be downloaded from root anyway. So relative paths will not do. So again propper DNS would save me. – Mak Sim Sep 07 '20 at 07:17