共计 746 个字符,预计需要花费 2 分钟才能阅读完成。
1. 阐明
本博客目标:解释 docker compose 两个不同 level 的 networks 作用,不便初学者。
注: 本文探讨的 Compose file format >= 3.0
2. 定义两级 networks
version: "3.9"
services:
proxy:
build: ./proxy
networks: ## Service-level networks key
- frontend
app:
build: ./app
networks: ## Service-level networks key
- frontend
- backend
db:
image: postgres
networks:
- backend
networks: ## Top-level networks key
frontend:
driver: brige
backend:
# Use a custom driver which takes special options
driver: brige
3. Top-level networks key
3.1 作用
指定 将要创立 的 networks.
(The top-level networks key lets you specify networks to be created.)
能够指定的 networks 信息:driver(比方 bridge, overlay),driver_opts 等
4. Service-level networks key
4.1 作用
指定要退出的 top-level networks key.
(Networks to join, referencing entries under the top-level networks key.)
O. 参考资料
<1> Networking in Compose
<2> top-level networks
<3> service-level networks key
正文完
发表至: docker-compose
2022-03-14