# external\_links

链接到docker-compose.yaml之外启动的容器上或者Compose外部的容器，特别是那些提供共享或者通用服务的容器。当指定容器名和链接的别名时（CONTAINER:ALIAS)，external\_link的语义类似于老的选项links。

```
 external_links:
   - redis_1
   - project_db_1:mysql
   - project_db_1:postgresql
```

Note:

外部创建的容器与它正在链接的服务必须至少连接到一个相同的网络中。Links选项是老版本的选项，现在推荐使用networks。

当以swarm模式部署一个stack时，external\_links会被忽视。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://camelgemonion.gitbook.io/docker/dockercompose.yaml-wen-jian-zhong-chang-yong-zhi-ling/untitled-12/external_links.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
