title: How to set up subdomains with traefik and docker in a local network?
body: <p>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 <code>raspy.local</code>. I can access docker containers via <code>raspy.local:&lt;portnumber&gt;</code>.</p>
  <p>What I would like to do is to have docker containers be reachable via subdomains, like <code>influxdb.raspy.local</code> or <code>traefik.raspy.local</code> etc. The only solution that worked was to run traefik as a docker container, set <code>Host(`&lt;subdomain&gt;.raspy.local`)</code> rules and edit the <code>/etc/hosts</code> file on my laptop so that the subdomains point to the IP address of the raspberry pi.</p>
  <p>This is a bad solution because I have to edit the <code>/etc/hosts</code> 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).</p>
  <p>What is the proper way to do it?</p>
  <p>(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)</p>