Open joubertredrat opened 1 year ago
podman-compose is not part of Podman.
Host name dns resolution only happens when a separate network is setup for containers, this should happen by default when uisng docker-compose/podman-compose.
@rhatdan Okay, I just mentioned podman-compose here because it's a "wrapper" running podman
internally.
About the hostname, I did this test.
podman network create my_networt_test
podman run \
--name=my_container_test_web1 \
-d \
-v /Users/dev/source/opensource/other/containers__podman-compose/tests/nets_test1/test1.txt:/var/www/html/index.txt:ro \
--net my_networt_test \
--network-alias web1,web1.alias \
-p 38001:8001 \
-w /var/www/html \
--hostname web1.hostname busybox /bin/busybox httpd -f -h /var/www/html -p 8001
podman run \
--name=my_container_test_web2 \
-d \
-v /Users/dev/source/opensource/other/containers__podman-compose/tests/nets_test1/test2.txt:/var/www/html/index.txt:ro \
--net my_networt_test \
--network-alias web2,web2.alias \
-p 38002:8001 \
-w /var/www/html \
--hostname web2.hostname busybox /bin/busybox httpd -f -h /var/www/html -p 8001
Inside this container my_container_test_web2
I executed this commands.
/var/www/html # hostname
web2.hostname
/var/www/html # nslookup web2
Server: 10.89.4.1
Address: 10.89.4.1:53
Non-authoritative answer:
Name: web2.dns.podman
Address: 10.89.4.6
Non-authoritative answer:
/var/www/html # nslookup web2.alias
Server: 10.89.4.1
Address: 10.89.4.1:53
Non-authoritative answer:
Name: web2.alias
Address: 10.89.4.6
Non-authoritative answer:
/var/www/html # nslookup web2.hostname
Server: 10.89.4.1
Address: 10.89.4.1:53
Non-authoritative answer:
** server can't find web2.hostname: NXDOMAIN
/var/www/html # nslookup web1
Server: 10.89.4.1
Address: 10.89.4.1:53
Non-authoritative answer:
Name: web1.dns.podman
Address: 10.89.4.5
Non-authoritative answer:
/var/www/html # nslookup web1.alias
Server: 10.89.4.1
Address: 10.89.4.1:53
Non-authoritative answer:
Name: web1.alias
Address: 10.89.4.5
Non-authoritative answer:
/var/www/html # nslookup web1.hostname
Server: 10.89.4.1
Address: 10.89.4.1:53
Non-authoritative answer:
** server can't find web1.hostname: NXDOMAIN
On container my_container_test_web2
, the itself hostname and aliases as resolved. From my_container_test_web1
, only aliases was resolved, hostname not.
My doubt is, is this expected behavior or it's a bug?
I'm also running into this issue while evaluating podman for my team's eventual replacement of docker. I may have found a possible contributing factor.
Since I installed podman with apt
, my version is a little behind. In particular, the CNI plugins that come with the ubuntu (wsl2) package are way behind. I kept getting warnings from several plugins that they don't "support config version 1.0.0," so I followed these instructions to get newer versions and fixed that error. If you look carefully at that list of plugins, you may notice that the dnsname
plugin is missing.
I moved dnsname
from the original plugins back into its proper location and finally got passed an error that was caused by not being able to resolve another service's network name, though with a difference from docker compose
. Under docker, I could use <service_name>.<network_name>
, but under podman I must instead use just <service_name>
(a mystery, since I've deliberately not changed my compose file from its known-good state with docker). It also seems like there's something of a delay before external DNS names can be resolved after rebuilding the container; my service would crash on the first connection outside the local network, but if I let it sit for a while and try again the same name gets resolved without issue.
In addition to dnsname
, the flannel
plugin is also not included in the CNI distribution. I don't know what flannel
does, but thought I'd mention it just in case.
Edit: I've noticed that ~/.config/cni/net.d/app.conflist
has "domainName": "dns.podman"
in the dnsname
options, and I can resolve <service_name>.dns.podman
inside a container. This might not be a "bug," but it is a significant difference from docker compose
. I have a network defined similar to this:
networks:
myapp:
driver: "bridge"
name: "myapp" # because having "my_app-myapp" as the tld is redundant and annoying
Under docker, the TLD is the network's name
, if set, else it's <project_name>-<network_id>
. Maybe it's more precise to say that the TLD is whatever is listed in the docker inspect
output under Name
. This behavior is what I was expecting, but I grant that it's not declared in the spec, so it might not be a bug in the truest sense (but it is "wrong," imo).
I haven't tried yet, but I assume I can workaround this by setting domainName
in the conflist file. That's... fine, I guess, but it's absolutely going to create friction in moving my team from docker. My ideal would be for podman-compose
to match the behavior of docker compose
, whether the spec says it must or not.
Issue Description
When you use
--hostname
onpodman run
, it's expected to hostname filled be resolvable inside the container itself and other containers that connect with this container. Actually the hostname is resolvable only inside container itself.Based on discuss in podman-compose repo. https://github.com/containers/podman-compose/discussions/730
Steps to reproduce the issue
Steps to reproduce the issue
podman-compose up -d
in a project that hostname defined is different from service name.Describe the results you received
Related container hostname not resolvable.
Describe the results you expected
Expected to ping related container by their hostname
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting