Fix DNS failures in the Claude Code Docker container
Recognise the failure
A DNS lookup can fail inside a running Docker container even while the host and a newly started container resolve names normally. In Claude Code, the visible symptom is:
API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN)
The distinguishing pattern is all three of these: the host resolves names, a fresh container resolves names, but the already-running Claude Code container keeps failing with EAI_AGAIN. The container may have worked before the host changed networks.
For example, the container starts while the host is using an iPhone Personal Hotspot on subnet 172.20.10.0/28 with nameserver 172.20.10.1. The host then moves to home Wi-Fi, whose DNS server is different. The host and a newly launched container use the home network, but the old container still points at 172.20.10.1.
Why the running container gets stuck
When Docker starts a container, it creates its /etc/resolv.conf using the DNS configuration available at that time. The running container keeps that resolver file after the host changes networks. If its DHCP-provided nameserver belongs to the old network and is no longer reachable, lookups in that container wait and eventually fail. The host resolver changing does not update the running container's frozen configuration.
This is why testing the host alone is misleading: the host has the new network settings, while the long-running container still has the old nameserver. A newly started container gets the current settings, which accounts for the different result.
Use stable DNS resolvers
start_claude.sh version 0.2.3 passes explicit public DNS servers to the docker run command: --dns 1.1.1.1 --dns 8.8.8.8. Docker no longer copies a network-specific DHCP nameserver into the container, so moving the host between networks does not leave a running session pointing at the previous network's DNS server.
Update the installed launcher from a checkout that contains version 0.2.3, then exit the affected session and start it again. The DNS settings are chosen when the container starts; changing the launcher cannot repair a container that is already running.
container/tools/ai/start_claude.sh --install-tools
The defaults can be replaced for a network that requires different DNS servers. Set CLAUDE_DNS to one or more space-separated resolver IP addresses before starting the installed launcher. For example, substitute DNS server addresses that are reachable and permitted on your network:
CLAUDE_DNS="192.0.2.53 192.0.2.54" ~/.local/share/start-claude/start_claude.sh
The addresses in this example are documentation-only placeholders; replace them with the resolver IPs you intend to use. The launcher passes each address as a Docker --dns option. Without CLAUDE_DNS, version 0.2.3 uses 1.1.1.1 and 8.8.8.8.
Article author: Arthur Isaev