/Docker 17

Link environment variables (superseded)

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 for details.

Environment variables will only be populated if you’re using the legacy version 1 Compose file format.

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.

To see what environment variables are available to a service, run docker-compose run SERVICE env.

Full URL, e.g. DB_PORT=tcp://

Full URL, e.g. DB_PORT_5432_TCP=tcp://

Container’s IP address, e.g. DB_PORT_5432_TCP_ADDR=

Exposed port number, e.g. DB_PORT_5432_TCP_PORT=5432

Protocol (tcp or udp), e.g. DB_PORT_5432_TCP_PROTO=tcp

Fully qualified container name, e.g. DB_1_NAME=/myapp_web_1/myapp_db_1

fig, composition, compose, docker, orchestration, cli, reference

© 2017 Docker, Inc.
Licensed under the Apache License, Version 2.0.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.
Docker, Inc. and other parties may also have trademark rights in other terms used herein.