add hostname to network alias

We use the name as alias but using the hostname makes also sense and
this is what docker does. We have to keep the short id as well for
docker compat.

While adding some tests I removed some duplicated tests that were
executed twice for nv for no reason.

Fixes #17370

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-07-11 15:38:24 +02:00
parent b6ec2127b8
commit f1c68b79eb
4 changed files with 19 additions and 54 deletions

View File

@@ -471,8 +471,10 @@ load helpers.network
run_podman run -d --network $netname $IMAGE top
background_cid=$output
local hostname=host-$(random_string 10)
# Run a httpd container on first network with exposed port
run_podman run -d -p "$HOST_PORT:80" \
--hostname $hostname \
--network $netname \
-v $INDEX1:/var/www/index.txt:Z \
-w /var/www \
@@ -490,7 +492,7 @@ load helpers.network
# check network alias for container short id
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").Aliases}}"
is "$output" "[${cid:0:12}]" "short container id in network aliases"
is "$output" "[${cid:0:12} $hostname]" "short container id and hostname in network aliases"
# check /etc/hosts for our entry
run_podman exec $cid cat /etc/hosts
@@ -550,7 +552,7 @@ load helpers.network
# check network2 alias for container short id
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname2\").Aliases}}"
is "$output" "[${cid:0:12}]" "short container id in network aliases"
is "$output" "[${cid:0:12} $hostname]" "short container id and hostname in network2 aliases"
# curl should work
run curl --max-time 3 -s $SERVER/index.txt