2015-06-07 22:59:58 +02:00
<!-- [metadata]>
+++
title = "Compose environment variables reference"
description = "Compose CLI reference"
keywords = ["fig, composition, compose, docker, orchestration, cli, reference"]
[menu.main]
parent="smn_compose_ref"
weight=3
+++
<![end-metadata]-->
# Compose environment variables reference
2014-01-27 16:03:21 +01:00
2015-10-22 09:17:11 +02:00
**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.md#links ) for details.
2014-08-08 19:59:08 +02:00
2015-01-20 18:29:28 +01:00
Compose uses [Docker links] 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.
2014-01-27 16:03:21 +01:00
2015-01-20 18:29:28 +01:00
To see what environment variables are available to a service, run `docker-compose run SERVICE env` .
2014-01-30 11:48:25 +01:00
2014-01-27 16:03:21 +01:00
< b >< i > name</ i > \_PORT</ b >< br >
2014-08-08 20:00:10 +02:00
Full URL, e.g. `DB_PORT=tcp://172.17.0.5:5432`
2014-01-27 16:03:21 +01:00
< b >< i > name</ i > \_PORT\_< i > num</ i > \_< i > protocol</ i ></ b >< br >
2014-08-08 20:00:10 +02:00
Full URL, e.g. `DB_PORT_5432_TCP=tcp://172.17.0.5:5432`
2014-01-27 16:03:21 +01:00
< b >< i > name</ i > \_PORT\_< i > num</ i > \_< i > protocol</ i > \_ADDR</ b >< br >
2014-08-08 20:00:10 +02:00
Container's IP address, e.g. `DB_PORT_5432_TCP_ADDR=172.17.0.5`
2014-01-27 16:03:21 +01:00
< b >< i > name</ i > \_PORT\_< i > num</ i > \_< i > protocol</ i > \_PORT</ b >< br >
2014-08-08 20:00:10 +02:00
Exposed port number, e.g. `DB_PORT_5432_TCP_PORT=5432`
2014-01-27 16:03:21 +01:00
< b >< i > name</ i > \_PORT\_< i > num</ i > \_< i > protocol</ i > \_PROTO</ b >< br >
2014-08-08 20:00:10 +02:00
Protocol (tcp or udp), e.g. `DB_PORT_5432_TCP_PROTO=tcp`
2014-01-27 16:03:21 +01:00
< b >< i > name</ i > \_NAME</ b >< br >
2014-01-27 18:46:46 +01:00
Fully qualified container name, e.g. `DB_1_NAME=/myapp_web_1/myapp_db_1`
2014-01-27 16:03:21 +01:00
2015-12-21 01:52:54 +01:00
[Docker links]: https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/
2015-02-25 09:43:33 +01:00
2015-10-13 13:01:19 +02:00
## Related Information
2015-02-25 09:43:33 +01:00
2015-10-13 13:01:19 +02:00
- [User guide ](index.md )
2015-05-12 13:44:43 +02:00
- [Installing Compose ](install.md )
2015-10-13 13:01:19 +02:00
- [Command line reference ](./reference/index.md )
2015-10-13 21:23:27 +02:00
- [Compose file reference ](compose-file.md )