Hi Trevor,
Trevor Vallender <trevor@tsvallender.co.uk> skribis:
> I have a Docker container which advertises its name using mDNS,
> e.g. hostname.local. However, when I restart the container,
> Docker assigns the container a new IP (not sure why, doesn't
> happen on other distros but that's probably not the point
> here). nscd has the old IP cached and doesn't refresh even though
> the container is advertising the new IP. I'm not sure why this
> behaviour is occurring, or if it is the expected behaviour?
I think so.
> I'm don't know the correct fix here but am open to suggestions. I
> presume one of the following:
>
> - Configure nscd not to cache mDNS addresses
> - Shorten the length of time these addresses are cached for
>
> If someone could suggest why this is occurring, or provide an
> example of how to do one of the above, that would be brilliant.
You can clear nscd’s host name cache with:
sudo herd invalidate nscd hosts
Better, you can configure nscd to disable caching along these lines:
(operating-system
;; …
(services
(modify-services %base-services ;or ‘%desktop-services’, etc.
(nscd-service-type
config => (nscd-configuration
(inherit config)
(caches '())))))) ;zero caches
More details here:
https://guix.gnu.org/manual/devel/en/html_node/Base-Services.html#index-nscd_002dconfiguration
HTH!
Ludo’.