Docker Compose – adding identifier to network name

Per https://docs.docker.com/compose/networking/:

Networks can also be given a custom name (since version 3.5):

version: "3.5"
networks:
  frontend:
    name: custom_frontend
    driver: custom-driver-1

So you could choose to simply name your network myNetwork like this:

networks:
  myNetwork:
    name: myNetwork
    driver: bridge

Alternatively, if you want your container to join an existing network (I know you say you want docker-compose to create the network for you, but for people reading this question this might be helpful), https://docs.docker.com/compose/networking/ states:

If you want your containers to join a pre-existing network, use the external option:

networks:
  default:
    external:
      name: my-pre-existing-network

Leave a Comment