CodexBloom - Programming Q&A Platform

scenarios to resolve DNS queries in Docker container running on Arch Linux

👀 Views: 2 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-03
docker linux dns bash

I'm refactoring my project and I'm stuck trying to I'm running a Docker container on Arch Linux and I'm working with an scenario where DNS queries are failing... When I try to ping a domain such as `google.com` from inside the container, I get the following behavior: ``` ping: google.com: Name or service not known ``` I've checked my Docker daemon configuration and it's using the default DNS settings. The `/etc/docker/daemon.json` file looks like this: ```json { "dns": [] } ``` I also validated that my host can resolve DNS queries without scenario. Using `nslookup` on the host machine returns the expected results: ``` someuser@arch:~$ nslookup google.com Server: 1.1.1.1 Address: 1.1.1.1#53 Non-authoritative answer: Name: google.com Address: 172.217.11.46 ``` To troubleshoot further, I tried running the container with custom DNS settings using the `--dns` flag: ```bash docker run --dns 1.1.1.1 -it mycontainer /bin/bash ``` However, this did not resolve the scenario; I'm still unable to resolve DNS from within the container. I've also looked into the network settings of the container using `docker network inspect bridge`, and they seem to be set up correctly. The container can access the internet, but not resolve domain names. I suspect there might be a conflict with the systemd-resolved service since Arch Linux uses it by default for DNS resolution. However, I tried disabling it and restarting Docker, but the question continues. I'm at a loss here. Any insights into what might be causing this DNS resolution failure in the Docker container on Arch Linux? I'm working with Bash in a Docker container on Ubuntu 22.04. Any ideas how to fix this?