Jump to content
dgwharrison

[solved] No DNS or DHCP lease?

10 posts in this topic Last Reply

Recommended Posts

Hi so my dockers are getting IPs the way they're supposed to, 172.17.0.2 for example. However they don't seem to be able to communicate with each other by hostname so I can't get sonarr to talk to sabnzbd by any other means than IP. The problem is when the dockers are restarted, be that the system or manually, they're given new IP addresses, reusing the old ones.  So say I tell sonarr to find sabnzbd on 172.17.0.2, after a reboot, it might be 172.17.0.3 and I have to manually reconfigure.

 

This sucks.  I've not used docker a lot, but I last time I did I recall being able to use host names.

 

I surely can't be the only one with this problem, so I figure I've missed something. Any ideas?

Edited by dgwharrison
solved

Share this post


Link to post

I don't have this problem.

Have you checked out any of @SpaceInvaderOne's videos?  It sounds like you didn't set up your dockers using (what I assume is) the common setup.

Pay special attention to the configuration section in this one for Sonarr for instance.

Share this post


Link to post
20 minutes ago, whipdancer said:

I don't have this problem.

Have you checked out any of @SpaceInvaderOne's videos?  It sounds like you didn't set up your dockers using (what I assume is) the common setup.

Pay special attention to the configuration section in this one for Sonarr for instance.

Yeah, I've done the same as he has. My problem is the IP isn't persistent, it's doled out 172.17.0.2, 172.17.0.3 etc in the order of the startup of the dockers. If you shut them all down then start them again in a different order they'll have different IP addresses. Which is obviously a pain...

Share this post


Link to post

The only thing I can think of is maybe my docker settings are wrong but there is nothing to adjust at all...

 

2018-11-09_00-30-51.thumb.png.6f1c1af149887fe75f19af5a71536f03.png

Edited by dgwharrison

Share this post


Link to post

Why are you giving your dockers their own IP addresses? I've watched almost all of his videos and I don't recall giving any of my dockers their own IP address.

Edited by whipdancer

Share this post


Link to post
10 minutes ago, whipdancer said:

Why are you giving your dockers their own IP addresses? I've watched almost all of his videos and I don't recall giving any of my dockers their own IP address.

Um, I didn't make my self clear I guess, because that's not what I'm doing.  What I said is that there appears to be no lease, not that there is no DHCP. DHCP is assigning 172.17.0.0/16 just fine the problem is it doesn't remember which docker (MAC address)  has which IP address.  This is generally referred to as the lease and for something like docker with a /16 subnet I would have thought that lease was forever in duration.

Share this post


Link to post

Given my limited knowledge of dockers....
For Unraid specifically...

I didn't create anything specific for my dockers when it comes to IP addresses.  All my dockers inherit my server's IP address.  My dockers are accessed via PORT number.

Did you change the default settings under settings > docker settings? (I think it's under settings for the docker engine)?

 

Edited by whipdancer
  • Like 1

Share this post


Link to post
5 hours ago, dgwharrison said:

Hi so my dockers are getting IPs the way they're supposed to, 172.17.0.2 for example. However they don't seem to be able to communicate with each other by hostname so I can't get sonarr to talk to sabnzbd by any other means than IP. The problem is when the dockers are restarted, be that the system or manually, they're given new IP addresses, reusing the old ones.  So say I tell sonarr to find sabnzbd on 172.17.0.2, after a reboot, it might be 172.17.0.3 and I have to manually reconfigure.

 

This sucks.  I've not used docker a lot, but I last time I did I recall being able to use host names.

 

I surely can't be the only one with this problem, so I figure I've missed something. Any ideas?

 

Is there any reason why you need to have the same ip assigned to a container or to connect through hostname each time it starts.

For most purposes you would use the servers ip address and the port which the container is using to access the container.

For example for me nzbget is on port 6789. So to access it i type the ip of my Unraid server (10.10.20.199) the the port

So 10.10.20.199:6789

1902673623_ScreenShot2018-11-08at17_53_19.thumb.png.d1d50642746bab495c01aa75f5947fff.png

 

So if i wanted to configure sonarr to talk to nzbget i would tell it to use that ip as that mapping will not change.

 

855570035_ScreenShot2018-11-08at17_45_52.thumb.png.d98ce87ce3dc3850998e46c408a64f35.png

 

However there may be use cases where by you might want to have containers talk by host name. For example using a reverse proxy

it is easier to use hostnames.

To do this you have to use a custom docker network. I showed how in the video i made on letsencypt reverse proxy here that you may want to check out.

https://youtu.be/I0lhZc25Sro?t=688

 

  • Like 1

Share this post


Link to post

Just to make things clear for everybody.

Docker networks do not have a real DHCP server in the the usual sense.

Docker networks do not interact with a DHCP server on that subnet either

What docker simply does is it grabs the next free IP in the docker network, and assign it to the container. If the container stops (or leaves the network), the IP is automatically marked as free and available for the next container that requests an IP.

 

The correct way to have DNS-like names is to do docker linking - which I don't like as its messy and doesn't persist across reboots

The other correct way that's persistent is to assign IP addresses to each container that needs it and add it into your LAN's DNS server.

  • Like 1

Share this post


Link to post

Hi @ken-ji, @SpaceinvaderOne & @whipdancer

 

Thanks for your help. I ended up solving this problem by switching the network of all my dockers back to host only and referring to each docker as localhost and using the port numbers. It works fine. 

 

@SpaceInvaderOne I was actually wondering about how to get an ssl certificate with lets encrypt so I will definitely watch that video thanks.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now