docker-compose tutorial: external_links connect external containers or services (deprecated in version 3)

In Docker Compose, external_linkskeywords are used to establish links with other Docker containers or external services.

This external_linksallows 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_linksexample uses of the keyword:

services:
  myservice:
    image: myimage
    external_links:
      - othercontainer:othercontainer
      - external-service:external-service

In the above example, myservicethe service is linked to othercontainera Docker container named and an external service named .external-service

external_linksThe 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_linksthe keyword has been deprecated in version 3 of Docker Compose and it is recommended to use service discovery or network linking instead.

Guess you like

Origin blog.csdn.net/a772304419/article/details/132913596