更新时间:2023-08-17 18:40:58
是的.在您的撰写文件中,您可以指定网络别名.
Yes. In your compose file, you can specify network aliases.
services:
db:
networks:
default:
aliases:
- database
- postgres
在此示例中,默认网络上的其他容器可以使用 db
、database
或 访问
.db
服务postgres
In this example, the db
service could be reached by other containers on the default network using db
, database
, or postgres
.
您还可以使用 为正在运行的容器添加别名docker network connect
命令和 --alias=
选项.
You can also add aliases to running containers using the docker network connect
command with the --alias=
option.