diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index 58508b99fc..195ce79567 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -989,6 +989,7 @@ Valid options for `[Pod]` are listed below: | DNSSearch=example.com | --dns-search example.com | | GIDMap=0:10000:10 | --gidmap=0:10000:10 | | GlobalArgs=--log-level=debug | --log-level=debug | +| HostName=name | --hostname=name | | IP=192.5.0.1 | --ip 192.5.0.1 | | IP6=2001:db8::1 | --ip6 2001:db8::1 | | Network=host | --network host | @@ -1057,6 +1058,15 @@ escaped to allow inclusion of whitespace and other control characters. This key can be listed multiple times. +### `HostName=` + +Set the pod’s hostname inside all containers. + +The given hostname is also added to the /etc/hosts file using the container’s primary IP address (also see the `--add-host` option). + +Equivalent to the Podman `--hostname` option. +This key can be listed multiple times. + ### `IP=` Specify a static IPv4 address for the pod, for example **10.88.64.128**. diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index 5a8d4ece37..889b43472e 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -417,6 +417,7 @@ var ( KeyDNSSearch: true, KeyGIDMap: true, KeyGlobalArgs: true, + KeyHostName: true, KeyIP: true, KeyIP6: true, KeyNetwork: true, @@ -1664,6 +1665,7 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]* KeyDNSOption: "--dns-option", KeyDNSSearch: "--dns-search", KeyAddHost: "--add-host", + KeyHostName: "--hostname", } lookupAndAddAllStrings(podUnit, PodGroup, allStringsKeys, execStartPre) diff --git a/test/e2e/quadlet/hostname.pod b/test/e2e/quadlet/hostname.pod new file mode 100644 index 0000000000..da30abf8a0 --- /dev/null +++ b/test/e2e/quadlet/hostname.pod @@ -0,0 +1,3 @@ +[Pod] +## assert-podman-pre-args "--hostname" "my-host-name" +HostName=my-host-name diff --git a/test/e2e/quadlet_test.go b/test/e2e/quadlet_test.go index eeb4f42c68..c182281b41 100644 --- a/test/e2e/quadlet_test.go +++ b/test/e2e/quadlet_test.go @@ -1076,6 +1076,7 @@ BOGUS=foo Entry("Pod - DNS Option", "dns-option.pod"), Entry("Pod - DNS Search", "dns-search.pod"), Entry("Pod - Host", "host.pod"), + Entry("Pod - HostName", "hostname.pod"), Entry("Pod - IP", "ip.pod"), Entry("Pod - Name", "name.pod"), Entry("Pod - Network", "network.pod"),