summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-22 08:50:32 -0400
committerGitHub <noreply@github.com>2022-04-22 08:50:32 -0400
commitad3da638ce17439a7adbf2aa7e1b4017d583f660 (patch)
tree4a975c6d37e9a3dad98b8e2f3119f58650589d5c /libpod/container.go
parent1bafde2d226067257d430c367ec2c53208d3eeeb (diff)
parente0f5bf279bd6aba1b018c2a2d7d31ee5a5f7b70b (diff)
downloadpodman-ad3da638ce17439a7adbf2aa7e1b4017d583f660.tar.gz
podman-ad3da638ce17439a7adbf2aa7e1b4017d583f660.tar.bz2
podman-ad3da638ce17439a7adbf2aa7e1b4017d583f660.zip
Merge pull request #13918 from Luap99/hosts
use etchosts package from c/common
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go
index bc3cab439..6e2b7f528 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -628,6 +628,15 @@ func (c *Container) RuntimeName() string {
// Hostname gets the container's hostname
func (c *Container) Hostname() string {
+ if c.config.UTSNsCtr != "" {
+ utsNsCtr, err := c.runtime.GetContainer(c.config.UTSNsCtr)
+ if err != nil {
+ // should we return an error here?
+ logrus.Errorf("unable to lookup uts namespace for container %s: %v", c.ID(), err)
+ return ""
+ }
+ return utsNsCtr.Hostname()
+ }
if c.config.Spec.Hostname != "" {
return c.config.Spec.Hostname
}