From f02d72fb760daeb8d1d0e3c4dd0031afa518729e Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 29 Jan 2018 12:22:23 -0600 Subject: libpod/container_api: Set hostname in ENV The container's hostname should be set as an environment variable for the container. Signed-off-by: baude Closes: #273 Approved by: baude --- libpod/container_api.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libpod') diff --git a/libpod/container_api.go b/libpod/container_api.go index cd3485880..c0ccdc212 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -268,6 +268,9 @@ func (c *Container) Init() (err error) { c.runningSpec.Annotations[crioAnnotations.Created] = c.config.CreatedTime.Format(time.RFC3339Nano) c.runningSpec.Annotations["org.opencontainers.image.stopSignal"] = fmt.Sprintf("%d", c.config.StopSignal) + // Set the hostname in the env variables + c.runningSpec.Process.Env = append(c.runningSpec.Process.Env, fmt.Sprintf("HOSTNAME=%s", c.config.Spec.Hostname)) + fileJSON, err := json.Marshal(c.runningSpec) if err != nil { return errors.Wrapf(err, "error exporting runtime spec for container %s to JSON", c.ID()) -- cgit v1.2.3-54-g00ecf