Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

dnsname does not resolve hostnames of containers #59

Open
DaTurr3t opened this issue Mar 11, 2021 · 6 comments
Open

dnsname does not resolve hostnames of containers #59

DaTurr3t opened this issue Mar 11, 2021 · 6 comments

Comments

@DaTurr3t
Copy link

DaTurr3t commented Mar 11, 2021

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

@mheon
Copy link
Member

mheon commented Mar 12, 2021

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?

@DaTurr3t
Copy link
Author

DaTurr3t commented Mar 12, 2021 via email

@rhatdan
Copy link
Member

rhatdan commented Mar 13, 2021

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

@mariot8
Copy link

mariot8 commented Oct 14, 2021

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.

@rhatdan
Copy link
Member

rhatdan commented Oct 14, 2021

@Luap99 @baude @mheon PTAL

@Luap99
Copy link
Member

Luap99 commented Oct 14, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants