Files
website/content/en/docs/concepts/containers/container-environment-variables.md
Takuya Tokuda 0502832cbb Ordering content by weight (#8787)
* ordering content by weight

* fix weight of 'setup' contents

* fix weight of 'concepts' contents

* fix weight of 'tasks' contents

* fix weight of 'tutorials' contents

* fix weight of 'reference' contents

* Revert "fix weight of 'tasks' contents"

This reverts commit 4b6916bed07c92c5f9eed75fb0a7ef0244266623.

* Revert "fix weight of 'tutorials' contents"

This reverts commit a1f783314337b1eb40017aef47a6bf1453d8c840.

* Revert "fix weight of 'setup' contents"

This reverts commit 91c8de366587eed25c803f8e7d5a59005adb6025.

* Revert "fix weight of 'reference' contents"

This reverts commit cc95605f6a9863f8a4ffb636178c69a80d302c3e.
2018-06-06 16:51:26 -07:00

68 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
reviewers:
- mikedanese
- thockin
title: Container Environment Variables
content_template: templates/concept
weight: 20
---
{{% capture overview %}}
This page describes the resources available to Containers in the Container environment.
{{% /capture %}}
{{< toc >}}
{{% capture body %}}
## Container environment
The Kubernetes Container environment provides several important resources to Containers:
* A filesystem, which is a combination of an [image](/docs/concepts/containers/images/) and one or more [volumes](/docs/concepts/storage/volumes/).
* Information about the Container itself.
* Information about other objects in the cluster.
### Container information
The *hostname* of a Container is the name of the Pod in which the Container is running.
It is available through the `hostname` command or the
[`gethostname`](http://man7.org/linux/man-pages/man2/gethostname.2.html)
function call in libc.
The Pod name and namespace are available as environment variables through the
[downward API](/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/).
User defined environment variables from the Pod definition are also available to the Container,
as are any environment variables specified statically in the Docker image.
### Cluster information
A list of all services that were running when a Container was created is available to that Container as environment variables.
Those environment variables match the syntax of Docker links.
For a service named *foo* that maps to a Container named *bar*,
the following variables are defined:
```shell
FOO_SERVICE_HOST=<the host the service is running on>
FOO_SERVICE_PORT=<the port the service is running on>
```
Services have dedicated IP addresses and are available to the Container via DNS,
if [DNS addon](http://releases.k8s.io/{{< param "githubbranch" >}}/cluster/addons/dns/) is enabled. 
{{% /capture %}}
{{% capture whatsnext %}}
* Learn more about [Container lifecycle hooks](/docs/concepts/containers/container-lifecycle-hooks/).
* Get hands-on experience
[attaching handlers to Container lifecycle events](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/).
{{% /capture %}}