diff options
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go index 57b894b26..831e4e886 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -643,3 +643,15 @@ func (c *Container) RWSize() (int64, error) { } return c.rwSize() } + +// Hostname gets the container's hostname +func (c *Container) Hostname() string { + if c.config.Spec.Hostname != "" { + return c.config.Spec.Hostname + } + + if len(c.ID()) < 11 { + return c.ID() + } + return c.ID()[:12] +} |