dnsname icon indicating copy to clipboard operation
dnsname copied to clipboard

dnsname does not resolve hostnames of containers

Open DaTurr3t opened this issue 3 years ago • 6 comments

The internal hostname of the container is not passed to dnsmasq, only the container name. Is it somehow possible to resolve the internal hostnames via dnsname?

EDIT: Some more Info

podman --version
podman version 2.0.5
#podman-plugins Version:
podman-plugins.x86_64 2.2.1-7.module+el8.3.1+9857+68fb1526

Example with a container:

podman run -d localhost/testcontainer:latest --name container1 --hostname somehostname
podman run -d localhost/testcontainer:latest --name container2
podman exec -it container2 bash
bash-4.2# host container1
container1 has address 192.168.0.29

Expected

bash-4.2# host somehostname
somehostname has address 192.168.0.29

Actual outcome

bash-4.2# host somehostname
Host somehostname not found: 3(NXDOMAIN)

Thank you and kind regards

DaTurr3t avatar Mar 11 '21 13:03 DaTurr3t

At present, this is not the intent of dnsname - it is intended to be used with container names only. However, since Podman 2.2.x, we do now support network aliases, which can be used to add additional names the container can be resolved by using DNS. We cannot automatically add the hostname, but you could manually do so using the --network-alias flag. Is this sufficient?

mheon avatar Mar 12 '21 19:03 mheon

Well, after testing the network alias feature, I can say that it should be optimal for my use case. Thank you very much for the heads-up.

Von: Matthew Heon @.> Gesendet: Freitag, 12. März 2021 20:13 An: containers/dnsname @.> Cc: Matthias Cotting @.>; Author @.> Betreff: Re: [containers/dnsname] dnsname does not resolve hostnames of containers (#59)

At present, this is not the intent of dnsname - it is intended to be used with container names only. However, since Podman 2.2.x, we do now support network aliases, which can be used to add additional names the container can be resolved by using DNS. We cannot automatically add the hostname, but you could manually do so using the --network-alias flag. Is this sufficient?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/containers/dnsname/issues/59#issuecomment-797694322 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQQ5CXW22NOGXUVQJK7HQLTDJKRHANCNFSM4ZAJHNGQ . https://github.com/notifications/beacon/AIQQ5CVDRYRSH4DTLZTVTEDTDJKRHA5CNFSM4ZAJHNG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF6F5S4Q.gif

DaTurr3t avatar Mar 12 '21 20:03 DaTurr3t

It does seem reasonable for podman to add the hostname to dnsname, @baude @mheon WDYT?

rhatdan avatar Mar 13 '21 12:03 rhatdan

Hi, I am in the process of transition to podman, trying to sunset docker usage in one of the projects. I hit the wall with the described container <-> container DNS name resolution. Would someone be so kind to point some new direction on how to debug this further and how to possibly work around it? As I feel like I shut off all the ideas I had so far and all doesn't seem to help. Would be grateful for any ideas.

[mariusz@x1-rhel8 ~]$ podman --version
podman version 3.2.3
[mariusz@x1-rhel8 ~]$ podman run --rm -d --network build --name postgres --network-alias postgres -e POSTGRES_USER=test -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=test postgres:9.6
7defce9d799d0fa956a2b1dcf39c45d4c7f62f4424098d330c4a7a885037a2eb
[mariusz@x1-rhel8 ~]$ podman run --rm --network build --name debug docker.io/library/alpine:latest cat /etc/resolv.conf && nslookup postgres
nameserver 10.0.2.3
Server:		10.0.2.3
Address:	10.0.2.3#53

** server can't find postgres: SERVFAIL
Name         : podman-plugins
Version      : 3.2.3
Release      : 0.11.module+el8.4.0+12050+ef972f71
Architecture : x86_64
Size         : 1.3 M
Source       : podman-3.2.3-0.11.module+el8.4.0+12050+ef972f71.src.rpm
Repository   : rhel-8-for-x86_64-appstream-rpms
Summary      : Plugins for podman
URL          : https://podman.io/
License      : ASL 2.0 and GPLv3+
Description  : This plugin sets up the use of dnsmasq on a given CNI network so
             : that Pods can resolve each other by name.  When configured,
             : the pod and its IP address are added to a network specific hosts file
             : that dnsmasq will read in.  Similarly, when a pod
             : is removed from the network, it will remove the entry from the hosts
             : file.  Each CNI network will have its own dnsmasq instance.

Name         : containernetworking-plugins
Version      : 0.9.1
Release      : 1.module+el8.4.0+11822+6cc1e7d7
Architecture : x86_64
Size         : 65 M
Source       : containernetworking-plugins-0.9.1-1.module+el8.4.0+11822+6cc1e7d7.src.rpm
Repository   : @System
From repo    : rhel-8-for-x86_64-appstream-rpms
Summary      : CNI network plugins
URL          : https://github.com/containernetworking/plugins
License      : ASL 2.0
Description  : The CNI (Container Network Interface) project consists of a specification
             : and libraries for writing plugins to configure network interfaces in Linux
             : containers, along with a number of supported plugins. CNI concerns itself
             : only with network connectivity of containers and removing allocated resources
             : when the container is deleted.

mariot8 avatar Oct 14 '21 11:10 mariot8

@Luap99 @baude @mheon PTAL

rhatdan avatar Oct 14 '21 12:10 rhatdan

@mariot8 Can you paste the output of podman network inspect build.

Luap99 avatar Oct 14 '21 12:10 Luap99