Defines multiple named networks for segmentation.
Section: Ports and Networks
Attach services to custom network
yaml
yaml
services:
web:
image: nginx:alpine
networks: ["frontend"]
api:
image: myapi:latest
networks: ["frontend", "backend"]
networks:
frontend: {}
backend: {}Explanation
Great for separating public and private service paths.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Ports and Networks