Help Needed: Docker Containers Can't Resolve Domain Names on Bridge Network

Help Needed: Docker Containers Can’t Resolve Domain Names on Bridge Network

Hi everyone,

I’m having trouble with my Docker setup on my home server. My containers on the bridge network can ping IP addresses but cannot resolve domain names. However, when using the host network, everything works fine. Here are the details:

Issue Description

When I enter a container using the bridge network and try to ping an IP address (e.g., 8.8.8.8), it works fine. However, attempting to ping a domain name (e.g., google.com) results in a temporary failure in name resolution.

Steps Taken

  1. Ping IP Address:

    root@pihole:/# ping 8.8.8.8
    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    64 bytes from 8.8.8.8: icmp_seq=1 ttl=113 time=47.4 ms
    64 bytes from 8.8.8.8: icmp_seq=2 ttl=113 time=46.9 ms
    64 bytes from 8.8.8.8: icmp_seq=3 ttl=113 time=46.8 ms
    
  2. Ping Domain Name:

    root@pihole:/# ping google.com
    ping: google.com: Temporary failure in name resolution
    

Configuration Details

  • Host DNS Configuration:

    root@tanix-tx6:~# cat /etc/resolv.conf
    # Generated by NetworkManager
    nameserver 192.168.1.1
    nameserver 2001:4860:4860::8888
    nameserver 2001:4860:4860::8844
    
  • Docker Network:

    root@tanix-tx6:~# docker network inspect bridge
    [
        {
            "Name": "bridge",
            "Id": "70bb26ec3707789535bb7d3330dc37377a1c17a14816bead670221c9d9b93580",
            "Created": "2024-05-25T08:44:25.063899697Z",
            "Scope": "local",
            "Driver": "bridge",
            "EnableIPv6": false,
            "IPAM": {
                "Driver": "default",
                "Options": null,
                "Config": [
                    {
                        "Subnet": "172.17.0.0/16",
                        "Gateway": "172.17.0.1"
                    }
                ]
            },
            "Internal": false,
            "Attachable": false,
            "Ingress": false,
            "ConfigFrom": {
                "Network": ""
            },
            "ConfigOnly": false,
            "Containers": {
                "78134bf84c7ac332bcbf06b9c2b38463f42b9dfec2882a9a4f1ec79c0273f3b8": {
                    "Name": "memos",
                    "EndpointID": "df06ce0ce691d0e8a4f78972e41160047a621ae44d216a604fbf3238a94e04b9",
                    "MacAddress": "02:42:ac:11:00:03",
                    "IPv4Address": "172.17.0.3/16",
                    "IPv6Address": ""
                },
                "986bd055e8dfa4800a9aec4dfe0b7da669d57aa0a39c87511ce6fbf795ef7ffe": {
                    "Name": "deluge",
                    "EndpointID": "a9270181c59b93cea615e29bf6988b932c566749cdff6545f487a6010569ee31",
                    "MacAddress": "02:42:ac:11:00:02",
                    "IPv4Address": "172.17.0.2/16",
                    "IPv6Address": ""
                }
            },
            "Options": {
                "com.docker.network.bridge.default_bridge": "true",
                "com.docker.network.bridge.enable_icc": "true",
                "com.docker.network.bridge.enable_ip_masquerade": "true",
                "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
                "com.docker.network.bridge.name": "docker0",
                "com.docker.network.driver.mtu": "1500"
            },
            "Labels": {}
        }
    ]
    

System Information

  • Docker Version: (e.g., 20.10.7)
  • Operating System: (e.g., Ubuntu 20.04 LTS)

Troubleshooting Steps

  1. Checked /etc/resolv.conf on the host and containers.
  2. Tried setting custom DNS servers in Docker daemon configuration.
  3. Restarted Docker service.

Does domain name resolution with DNS work inside other containers, without pihole? Is pihole configured correctly? What does docker info tell you?

same issue with every container.