Jump to content

Accessing docker containers by name on local network (BANGING MY HEAD AGAINST THE WALL)


Recommended Posts

I am about to go nuts trying to get local DNS working and accessing my docker contaiers by name on my local network. For reference I am using a Unifi UDM Pro for my router.

 

I've had my Unraid server running for a few years now and have always used IP:PORT to access containers on my local network. I have also been using NPM to access the containers from an external network. I just recently got the itch to do some tinkering and swap over to using Tailscale VPN in order to access my containers remotely instead of NPM. I wanted to get local hostnames working so that once I start using Tailscale I can just turn on the Tailscale VPN and then type in my local host names and access the containers easily.

 

I thought this would be as simple as setting up local DNS records in my UDMPro that reroute DNS requests from x.y.local to container IP:PORT. After doing that it didn't work so I have done a ton of research and tried all of the following and still have had 0 success.

 

  1. Enabled host access to custom networks
  2. Placed all containers that I would like to access remotely on a custom docker network
    1. I also tried placing NPM container on br0 in order to give it its own static IP on my local network
  3. Created proxy host in NPM that uses sonarr.x.y to forward to Sonarr container HTTP IP:PORT
  4. Created local DNS record in UDMPro that redirects sonarr.x.y to NPM IP
  5. I even installed NextDNS on my UDMPro thinking that maybe the UDMPro wasn't handling local DNS records correctly and am still seeing the same behavior

 

I have verified that I can access the containers using their IP:PORT, but for some reason using local names is still not working. I can also still access them remotely using NPM, but just can't access them on my local network by name.

 

I threw some screenshots in the Imgur album here for reference if needed: https://imgur.com/a/RiiYxID

Link to comment

If youre using tailscale, depening on the setup you wanna have a look at https://tailscale.com/kb/1081/magicdns
Since i dont use tailscale at all, i dont know how its configured and if it even fetches remote dns server.

Also, youre aware that you need to include the port in the domain name? because npm is running on a non standard port, you always have to call "example.home:1880" or "example.home:18443" for https
OR if you, as you said, decided to run NPM on br0 in your lan  "example.home:8080" or "example.home:4443" for https

theres no port forwarding magic without portforwarding.


Edit: Added some pictures, works like a charm


Container.PNG.3d212875e3a616bfc39175a603a9cefb.PNG
NPM Setting:
NPMSetting.PNG.1b3895e05279a9786df17b886813515c.PNG
DNS-Rewrite:
DNS.PNG.b8f6aa9d51d9da349ef49be48a7c126b.PNG
Result:
Result.PNG.ab618a9995e96eacaa5f067d40e849e1.PNG

Edited by Mainfrezzer
Link to comment
Posted (edited)
6 hours ago, Mainfrezzer said:

If youre using tailscale, depening on the setup you wanna have a look at https://tailscale.com/kb/1081/magicdns
Since i dont use tailscale at all, i dont know how its configured and if it even fetches remote dns server.

Also, youre aware that you need to include the port in the domain name? because npm is running on a non standard port, you always have to call "example.home:1880" or "example.home:18443" for https
OR if you, as you said, decided to run NPM on br0 in your lan  "example.home:8080" or "example.home:4443" for https

theres no port forwarding magic without portforwarding.


Edit: Added some pictures, works like a charm


Container.PNG.3d212875e3a616bfc39175a603a9cefb.PNG
NPM Setting:
NPMSetting.PNG.1b3895e05279a9786df17b886813515c.PNG
DNS-Rewrite:
DNS.PNG.b8f6aa9d51d9da349ef49be48a7c126b.PNG
Result:
Result.PNG.ab618a9995e96eacaa5f067d40e849e1.PNG

Interesting, I had not been inputting the ports - I kind of thought that was part of the whole point of this was to not have to worry about inputting the IP or port and only using the local name.

 

However using your input I was able to get it working with NPM set on the same docker network as my containers and adding the port at the end.

 

So with that being said, if I did want to not have to type in the port number every time as well, how would I get that working in order to only have to type in example.local with no port?

 

Also to add onto your Tailscale point - I believe MagicDNS only works for unique machines, so it wouldn't work for docker container addresses, only for unique machines that had an instance of Tailscale running on them.

Edited by semicole
Link to comment
Posted (edited)
9 minutes ago, Mainfrezzer said:

80 for http and 443 for https.

So I would just need to adjust my NPM container to use the default 80 and 443 ports as opposed to 1880 and 4443 and then it should work using only the local names with no ports designated?

 

Edit: That did it thanks!

Edited by semicole
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...