Docker Compose - adding identifier to network name

后端 未结 3 2196
猫巷女王i
猫巷女王i 2021-02-07 09:53

I trying to create network in docker-compose.vs.debug.yml file:

networks:
  myNetwork:
    driver: bridge

But docker adding some identifier:

3条回答
  •  无人及你
    2021-02-07 10:27

    I assume you use a VS2017 dcproj. I solved this by creating the network manually in the dcproj project as a PreBuildEvent. Add a prebuild target to the .dcproj file:

    
        
        
    
    

    Then in your docker-compose files you can specify an external network:

    networks:
      default:
        external:
          name: customnetwork
    

    Requires you to start the dcproj before other projects or add the same prebuild exec to all the projects that should share the network.

提交回复
热议问题