Docker DNS

We have a web-based research prototype that allows for multi-browser interaction on multiple devices. For example, interactions in a browser on a tablet would be reflected in the browser on my laptop. Since this is still in development, I also run the server on my laptop.

This was all fine until we introduced the security service into our development branch (provided by another partner in our consortium). The system now uses cas authentication, which is reliant on a specific domain name rather than just an IP address. For example, if the system was called sausages, we would need to connect via the url http://sausages:9090. To solve this locally, we just modify the hosts file on development machines. The issue is that I can no longer connect from the tablet since the tablet has no idea how to resolve the domain name ‘sausages’. I could root the tablet and modify its host file, but I’d prefer not to go down that route since I’d have to modify it every time my laptop’s IP address changes.

The solution I came up with was to use dnsmasq as a lightweight DNS server on my laptop. Since we’re already using docker in the project, it was easy enough to add it our existing compose file. However, there is still the issue that the DNS lookup for sausages would need to change every time my laptop’s IP changed.

To address this, I created a small network (literally) using a TP-Link TL-WR702N wireless router (see below). This thing is 57mm*57mm*18mm in size and can be powered from USB. I configured its DHCP settings such that my laptop always has the same IP, which is also added as a DNS address. Then I plug it into my laptop’s USB port and connect both the laptop and tablet. Hey presto! Without changing the config of either the laptop or tablet, I can go to http://sausages:9090 in the browser on the tablet and connect to the server on the laptop (resolved via dnsmasq on the laptop).

The only disadvantage is that it takes my laptop off my main network. However, I can connect to the router either wirelessly or wired, so I can always use the other option to connect to two networks at once.