Reputation: 2005
I have a raspberry pi plugged into my home router, running Ubuntu 20.04 and Docker.
I gave it a fixed ip and its hostname in the local network is raspy.local
. I can access docker containers via raspy.local:<portnumber>
.
What I would like to do is to have docker containers be reachable via subdomains, like influxdb.raspy.local
or traefik.raspy.local
etc. The only solution that worked was to run traefik as a docker container, set Host(`<subdomain>.raspy.local`)
rules and edit the /etc/hosts
file on my laptop so that the subdomains point to the IP address of the raspberry pi.
This is a bad solution because I have to edit the /etc/hosts
file every time I make a change and anyways this cannot be done on all the devices on my network (e.g. I cannot to it on smartphones).
What is the proper way to do it?
(I have found other similar questions here on SO, but I didn't find one with information on how to do this within a local network)
Upvotes: 3
Views: 6480
Reputation: 1277
You need to setup a local DNS server:
Now every device connected to the router is going to be able to reach the Traefik server using domain names.
#30daysofstackoverflow
Upvotes: 1