Docker Compose: A Mini Orchestration Tool for Local Development
57%
Creating Custom Networks
By default, a network is created for all the services in a single Compose file even when it's not defined explicitly in the YAML file. However, we can create a custom network if we want to. Here is an example:
services:
front:
image: front-image
networks:
- mynet
networks:
my_net:
Adding networks created by users can be useful when you want to:
- Define custom network settings such as driver, driver options, and name.
services:
front:
image: front-image
networks:
- mynet
networks:
my_net:
driver: bridge
- Create multiple networks and connect services to different networks. For example, you can create a frontend network and a backend network and connect the frontend services to the frontend network and the backend services to the backend network.
services:
front:
image: front-image
networks:
- frontend
api:
image: api-image
networks:
- backend
- frontend
redis:
image: redis
networks:
- backend
networks:
frontend:
backend:
Painless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Unlock now  $31.99$25.59Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
