Docker DNS Error on Raspberry Pi

I have a Raspberry Pi 3 Model B Plus Rev 1.3, running Debian GNU/Linux 12 (bookworm). uname -a prints:

Linux raspberrypi 6.12.25+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux

It is running Docker version 28.5.1, build e180ab8.

I have a Docker container that works fine when run in Docker on my PC, but when run on my Raspberry Pi, I get DNS errors.

The bot’s log output, on Docker in Raspbian, is:

logging output
Logging in
node:internal/deps/undici/undici:14900
      Error.captureStackTrace(err);
            ^

TypeError: fetch failed
    at node:internal/deps/undici/undici:14900:13
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  [cause]: Error: getaddrinfo EAI_AGAIN lemmy.zip
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
    errno: -3001,
    code: 'EAI_AGAIN',
    syscall: 'getaddrinfo',
    hostname: 'lemmy.zip'
  }
}

Node.js v22.21.1

If I do ping lemmy.zip, outside of Docker, it works absolutely fine.

My Pi’s DNS settings are:

/etc/resolv.conf
search Home
nameserver 9.9.9.9
nameserver 149.112.112.112

I assume, but do not know for sure, that this is loosely related to my earlier issue with even doing a docker pull, which users on here were able to successfully assist me with, and reducing my resolv.conf down to what it is now seemed to be the solution.

I have created this minimal script to test it out. It makes an HTTP request to a list of sample sites and returns if it was able to contact them.

Code
const https = require('https');

const TEST_ENDPOINTS = [
  'https://www.google.com',
  'https://api.github.com',
  'https://www.nytimes.com/games/connections',
  'https://example.com',
  'https://lemmy.zip'
];

function testConnection(url) {
  return new Promise((resolve, reject) => {
    const req = https.get(url, { timeout: 5000 }, (res) => {
      res.on('data', () => {});
      res.on('end', () => resolve(true));
    });

    req.on('error', reject);
    req.on('timeout', () => {
      req.destroy();
      reject(new Error('Timeout'));
    });
  });
}

async function main() {
  const results = await Promise.allSettled(
    TEST_ENDPOINTS.map(url => testConnection(url))
  );
  
  const successCount = results.filter(r => r.status === 'fulfilled').length;
  console.log(`\n${successCount}/${results.length} successful`);
  process.exit(successCount === 0 ? 1 : 0);
}

main();

If I run it with npm start on my PC, or by building a Docker container and then running the container on my PC, it works. The output is 5/5 successful. But when I build it on my Raspberry Pi and run the Docker container on there, it is 0/5 successful

The whole point of this is not to install Node directly on the Pi, but I simulated the same code by running

curl -s -o /dev/null -w "%{http_code}" --max-time 5 https://www.google.com
curl -s -o /dev/null -w "%{http_code}" --max-time 5 https://api.github.com
curl -s -o /dev/null -w "%{http_code}" --max-time 5 https://www.nytimes.com/games/connections
curl -s -o /dev/null -w "%{http_code}" --max-time 5 https://example.com
curl -s -o /dev/null -w "%{http_code}" --max-time 5 https://lemmy.zip

In every case, the result was 200.

Just to be safe, I also did

wget -q --spider --timeout=5 https://www.google.com && echo "success" || echo "fail"
wget -q --spider --timeout=5 https://api.github.com && echo "success" || echo "fail"
wget -q --spider --timeout=5 https://www.nytimes.com/games/connections && echo "success" || echo "fail"
wget -q --spider --timeout=5 https://example.com && echo "success" || echo "fail"
wget -q --spider --timeout=5 https://lemmy.zip && echo "success" || echo "fail"

I get five successes.

If I run it with

docker run --network host docker-network-test

It is able to succeed, getting 5/5. I’m not 100% sure what this does, or if/why it’s bad to do. It certainly feels inelegant.

I saw some other guides suggesting something about a Docker bridge, but as far as I can tell that should be for connections between pods, not necessary for connecting a Docker pod to the Internet?

Are you using the same DNS resolvers on your PC?

On the Pi, cat /etc/resolv.conf:

# Generated by NetworkManager
search Home
nameserver 9.9.9.9
nameserver 149.112.112.112

On my PC, on Windows, Network settings show IPv4 DNS servers: 9.9.9.9, 149.112.112.112

And just to be safe, my router’s LAN IPv4 setting has:

Primary DNS Server: 9.9.9.9
Secondary DNS Server: 149.112.112.112

And its WAN connection has:

Primary DNS Server: 9.9.9.9
Secondary DNS Server: 149.112.112.112


I also tried running, on the Pi:

$ docker run --rm alpine nslookup google.com
nslookup: can't connect to remote host (9.9.9.9): Network unreachable

So the problem seems not to be with the DNS configuration, but something else.

What are you running exactly? Where did you get the “Debian GNU/Linux 12 (bookworm)” image?

Why not run Raspberry Pi OS, which is Pi-customized and a derivative of Debian?