compose: move deprecated env-vars section, and fix duplicate redirects

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-10-07 10:24:31 +02:00
parent 0bbe9c32fb
commit 2eff941697
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 48 additions and 58 deletions

View File

@ -1,8 +1,6 @@
--- ---
description: Compose file reference description: Compose file reference
keywords: fig, composition, compose version 1, docker keywords: fig, composition, compose version 1, docker
redirect_from:
- /compose/yml
title: Compose file version 1 reference title: Compose file version 1 reference
toc_max: 4 toc_max: 4
toc_min: 1 toc_min: 1
@ -442,6 +440,46 @@ Links also express dependency between services in the same way as
> links between them must share at least one network in common in order to > links between them must share at least one network in common in order to
> communicate. > communicate.
#### link environment variables
> [Version 1 file format](compose-versioning.md#version-1) only. In version 2 and
> up, custom networks are used, and no environment variables are created.
> **Note**
>
> Environment variables are no longer the recommended method for connecting to
> linked services. Instead, you should use the link name (by default, the name
> of the linked service) as the hostname to connect to. Refer to the
> [docker-compose.yml documentation](compose-file/index.md#links) for details.
>
> Environment variables are only populated if you use the
> [legacy version 1 Compose file format](compose-file/compose-versioning.md#versioning).
{: .warning }
Compose uses [Docker links](../../network/links.md)
to expose services' containers to one another. Each linked container injects a set of
environment variables, each of which begins with the uppercase name of the container.
To see what environment variables are available to a service, run `docker-compose run SERVICE env`.
<b><i>name</i>\_PORT</b><br>
Full URL, such as `DB_PORT=tcp://172.17.0.5:5432`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i></b><br>
Full URL, such as `DB_PORT_5432_TCP=tcp://172.17.0.5:5432`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i>\_ADDR</b><br>
Container's IP address, such as `DB_PORT_5432_TCP_ADDR=172.17.0.5`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i>\_PORT</b><br>
Exposed port number, such as `DB_PORT_5432_TCP_PORT=5432`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i>\_PROTO</b><br>
Protocol (tcp or udp), such as `DB_PORT_5432_TCP_PROTO=tcp`
<b><i>name</i>\_NAME</b><br>
Fully qualified container name, such as `DB_1_NAME=/myapp_web_1/myapp_db_1`
### log_driver ### log_driver
> [Version 1 file format](compose-versioning.md#version-1) only. In version 2 and up, use > [Version 1 file format](compose-versioning.md#version-1) only. In version 2 and up, use

View File

@ -1,8 +1,6 @@
--- ---
description: Compose file reference description: Compose file reference
keywords: fig, composition, compose version 3, docker keywords: fig, composition, compose version 3, docker
redirect_from:
- /compose/yml
title: Compose file version 2 reference title: Compose file version 2 reference
toc_max: 4 toc_max: 4
toc_min: 1 toc_min: 1

View File

@ -453,10 +453,8 @@ It's more complicated if you're using particular configuration features:
options: options:
syslog-address: "tcp://192.168.0.42:123" syslog-address: "tcp://192.168.0.42:123"
- `links` with environment variables: As documented in the - `links` with environment variables: environment variables created by
[environment variables reference](../link-env-deprecated.md), environment variables links, such as `CONTAINERNAME_PORT`, ` have been deprecated for some time. In the new Docker network system,
created by
links have been deprecated for some time. In the new Docker network system,
they have been removed. You should either connect directly to the they have been removed. You should either connect directly to the
appropriate hostname or set the relevant environment variable yourself, appropriate hostname or set the relevant environment variable yourself,
using the link hostname: using the link hostname:

View File

@ -2,6 +2,9 @@
title: Environment variables in Compose title: Environment variables in Compose
description: How to set, use and manage environment variables in Compose description: How to set, use and manage environment variables in Compose
keywords: compose, orchestration, environment, env file keywords: compose, orchestration, environment, env file
redirect_from:
- /compose/env
- /compose/link-env-deprecated
--- ---
There are multiple parts of Compose that deal with environment variables in one There are multiple parts of Compose that deal with environment variables in one
@ -192,8 +195,6 @@ documented in [CLI Environment Variables](reference/envvars.md).
## Environment variables created by links ## Environment variables created by links
When using the ['links' option](compose-file/index.md#links) in a When using the ['links' option](compose-file/index.md#links) in a
[v1 Compose file](compose-file/index.md#version-1), environment variables are created [v1 Compose file](compose-file/compose-file-v1.md#link-environment-variables),
for each link. They are documented in environment variables are created for each link. These variables are deprecated.
the [Link environment variables reference](link-env-deprecated.md). Use the link alias as a hostname instead.
However, these variables are deprecated. Use the link alias as a hostname instead.

View File

@ -1,45 +0,0 @@
---
description: Compose CLI reference
keywords: fig, composition, compose, docker, orchestration, cli, reference
redirect_from:
- /compose/env
title: Link environment variables (superseded)
notoc: true
---
> **Note**: Environment variables are no longer the recommended method for connecting to linked services. Instead, you should use the link name (by default, the name of the linked service) as the hostname to connect to. See the [docker-compose.yml documentation](compose-file/#links) for details.
>
> Environment variables are only populated if you're using the [legacy version 1 Compose file format](compose-file/compose-versioning.md#versioning).
Compose uses [Docker links](../network/links.md)
to expose services' containers to one another. Each linked container injects a set of
environment variables, each of which begins with the uppercase name of the container.
To see what environment variables are available to a service, run `docker-compose run SERVICE env`.
<b><i>name</i>\_PORT</b><br>
Full URL, such as `DB_PORT=tcp://172.17.0.5:5432`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i></b><br>
Full URL, such as `DB_PORT_5432_TCP=tcp://172.17.0.5:5432`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i>\_ADDR</b><br>
Container's IP address, such as `DB_PORT_5432_TCP_ADDR=172.17.0.5`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i>\_PORT</b><br>
Exposed port number, such as `DB_PORT_5432_TCP_PORT=5432`
<b><i>name</i>\_PORT\_<i>num</i>\_<i>protocol</i>\_PROTO</b><br>
Protocol (tcp or udp), such as `DB_PORT_5432_TCP_PROTO=tcp`
<b><i>name</i>\_NAME</b><br>
Fully qualified container name, such as `DB_1_NAME=/myapp_web_1/myapp_db_1`
## Related information
- [User guide](index.md)
- [Installing Compose](install.md)
- [Getting Started](gettingstarted.md)
- [Command line reference](reference/index.md)
- [Compose file reference](compose-file/index.md)
- [Sample apps with Compose](samples-for-compose.md)