Creating A New Network Bridge

We can create a new Network Bridge in docker compose like following:

networks:
  server_net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/16

For example in here, we create a network server_net. By default, docker will reserve the .1 as a Docker Default Gateway.

So in this case it's 172.20.0.1. In our container of 172.20.0.0/16 subnets.

We're able to talk to the host machine (your MacOS or Linux or Windows) via 172.20.0.1