Docker Community Forums

Share and learn in the Docker community.

Docker-compose network abstraction


(Manilonkar) #1

I have compose file

version: "2.4"
services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    depends_on:
      - AService
    networks:
      - test-network

    AService:
    image: ubuntu:latest
    ports:
      - "80:80"
    depends_on:
      - BService
    networks:
      - test-network
 .....

networks:
    test-network:
    name: test-network
    ipam:
      driver: default
      config:
      - subnet: 10.10.10.0/24

I want to abstract out the network from each service since there are N services. Dose extend do this https://docs.docker.com/compose/extends/#example-use-case-1

So I can have a compose file for docker network & then use that in other places.


I found this example for extending services, but I am not clear if its applicable to networks.