In Docker Compose, external_links
keywords are used to establish links with other Docker containers or external services.
This external_links
allows you to link services in the current Compose file with other Docker containers or external services so that they can communicate with each other.
Here are external_links
example uses of the keyword:
services:
myservice:
image: myimage
external_links:
- othercontainer:othercontainer
- external-service:external-service
In the above example, myservice
the service is linked to othercontainer
a Docker container named and an external service named .external-service
external_links
The syntax of the keyword is <container/hostname>:<alias>
where <container/hostname>
is the name of the container or host to be linked and <alias>
is the alias of the link that can be used within the service to access the linked container or service.
Note that external_links
the keyword has been deprecated in version 3 of Docker Compose and it is recommended to use service discovery or network linking instead.