[GH-ISSUE #198] Unable to resolve container name to IP address #79

Closed
opened 2026-02-26 04:33:59 +03:00 by kerem · 2 comments
Owner

Originally created by @sovereignstack on GitHub (May 25, 2020).
Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/198

What is Happening

dns-proxy-server is unable to resolve container name even when right environment variables are set and config settings are done.

  • Describe what is happening instead
ping ngtest
ping: ngtest: Name or service not known
  • Please also describe how to reproduce

#Run a test nginx container
sudo docker run -d --name=ngtest nginx

#Run dns-proxy-server

sudo docker run -d \
--restart unless-stopped \
--name dns-proxy-server \
-p 5380:5380 \
-e MG_REGISTER_CONTAINER_NAMES=true \
--hostname dns.mageddo \
-v /opt/dns-proxy-server/conf:/app/conf \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/resolv.conf:/etc/resolv.conf defreitas/dns-proxy-server

#Try pinging ngtest from host
ping ngtest

What is expected

Something like

PING ngtest (172.17.0.5) 56(84) bytes of data.
...
...

Describe what you expected to happen and why

Steps to Reproduce

Describe which steps should be followed to reproduce the issue

Specs:

  • OS: [e.g. Ubuntu 18.04]
  • Docker Version: Docker CE 19.03.5
  • DPS Version: 2.19.0
  • Please attach DPS Log file
    log.txt
    conf.json.txt

Update:

I noticed that if I ping Container ID it works. But this is not the solution as container ID is cryptic and I want to use container names.

Originally created by @sovereignstack on GitHub (May 25, 2020). Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/198 ### What is Happening dns-proxy-server is unable to resolve container name even when right environment variables are set and config settings are done. * Describe what is happening instead ``` ping ngtest ping: ngtest: Name or service not known ``` * Please also describe how to reproduce #Run a test nginx container `sudo docker run -d --name=ngtest nginx` #Run dns-proxy-server ``` sudo docker run -d \ --restart unless-stopped \ --name dns-proxy-server \ -p 5380:5380 \ -e MG_REGISTER_CONTAINER_NAMES=true \ --hostname dns.mageddo \ -v /opt/dns-proxy-server/conf:/app/conf \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /etc/resolv.conf:/etc/resolv.conf defreitas/dns-proxy-server ``` #Try pinging ngtest from host `ping ngtest` ### What is expected Something like ``` PING ngtest (172.17.0.5) 56(84) bytes of data. ... ... ``` Describe what you expected to happen and why ### Steps to Reproduce Describe which steps should be followed to reproduce the issue **Specs:** - OS: [e.g. Ubuntu 18.04] - Docker Version: Docker CE 19.03.5 - DPS Version: 2.19.0 - Please attach DPS Log file [log.txt](https://github.com/mageddo/dns-proxy-server/files/4677186/log.txt) [conf.json.txt](https://github.com/mageddo/dns-proxy-server/files/4677188/conf.json.txt) ### Update: I noticed that if I ping Container ID it works. But this is not the solution as container ID is cryptic and I want to use container names.
kerem 2026-02-26 04:33:59 +03:00
Author
Owner

@royduin commented on GitHub (Jun 25, 2020):

Copy the content of /etc/resolv.conf and then remove it with: sudo rm /etc/resolv.conf, next recreate the file with Nano or Vim: vi /etc/resolv.conf and paste the content. Then restart the container.

<!-- gh-comment-id:649742470 --> @royduin commented on GitHub (Jun 25, 2020): Copy the content of `/etc/resolv.conf` and then remove it with: `sudo rm /etc/resolv.conf`, next recreate the file with Nano or Vim: `vi /etc/resolv.conf` and paste the content. Then restart the container.
Author
Owner

@mageddo commented on GitHub (Jul 9, 2020):

I think it's related to this discurssion, DPS can't deal with hostnames without a domain, it conflicts with some other Linux features.

Try add a domain to your host, like ngtest.intranet or ngtest.docker, don't ngtest.local or simply ngtest

<!-- gh-comment-id:656403827 --> @mageddo commented on GitHub (Jul 9, 2020): I think it's related to [this discurssion][1], DPS can't deal with hostnames without a domain, it conflicts with some other Linux features. Try add a domain to your host, like ngtest.intranet or ngtest.docker, don't ngtest.local or simply ngtest [1]: https://github.com/mageddo/dns-proxy-server/issues/163
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/dns-proxy-server-mageddo#79
No description provided.