Any debugging / general advice on how I could have caught this weird error?
I just spent a whole day on a very irritating gotcha, and I'm looking to see if there's a big-picture approach that can keep me from ending up here again.
Fairly new to Docker. Working on containerizing a web app with a couple different moving parts. Got the frontend working inside of a Caddy image, got it pushed to my DigitalOcean droplet, but then it just sat there, not acknowledging or even rejecting any requests. I figured out that it had crashed because it tried to serve to a busy port, but after clearing that up it still wasn't working. Looked in the logs, and there were some opaque errors about failing to connect to the internet (I've since deleted those logs, otherwise I'd share).
I threw these logs at an LLM, and after some arguing, it asked me to run nslookup web1 inside of the container. That returned:
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find web1: SERVFAIL
From this output, the LLM suggested that:
- Caddy, not receiving any defaults for
resolv.conf, had inherited from the droplet'sresolv.conf, which listens on port 53, which is just a loopback; thus, no connection. - The fix was to add
dns: [1.1.1.1,8.8.8.8]to the compose file, or alternatively to the droplet's daemon.json file to apply for the whole droplet.
Did this, rebuilt the container, and sure enough, that was exactly the issue.
And now I'm questioning everything. How the hell would anyone have caught this? Did I overlook a search result or documentation that explains exactly what I saw? Do I not know enough about Linux to be using Docker? Am I a soydev????
For real though, I'd appreciate any advice. I could've easily spent a week on this if I hadn't used AI, but I wanna gain the knowledge to be more self-reliant. Did I miss something critical, or is this just one of those things that you don't learn til you get burned?