Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup multiple visual studio solutions working together using docker compose (with debugging)

Lots of questions seem to have been asked about getting multiple projects inside a single solution working with docker compose but none that address multiple solutions.

To set the scene, we have multiple .NET Core APIs each as a separate VS 2019 solution. They all need to be able to use (as a minimum) the same RabbitMQ container running locally as this deals with all of the communication between the services.

I have been able to get this setup working for a single solution by:

  • Adding 'Container orchestration support' for an API project.
  • This created a new docker-compose project in the solution I did it for.
  • Updating the docker-componse.yml to include both a RabbitMQ and MongoDb image (see image below - sorry I couldn't get it to paste correctly as text/code):

enter image description here

Now when I launch all new RabbitMQ and MongoDB containers are created.

I then did exactly the same thing with another solution and unsurprisingly it wasn't able to start because the RabbitMQ ports were already in use (i.e. it tried to create another new RabbitMQ image).

I kind of expected this but don't know the best/right way to properly configure this and any help or advice would be greatly appreciated.

like image 811
Ben Thomson Avatar asked Jul 21 '26 00:07

Ben Thomson


1 Answers

I have been able to compose multiple services from multiple solutions by setting the value of context to the appropriate relative path. Using your docker-compose example and adding my-other-api-project you end up with something like:

services:
    my-api-project:
      <as you have it currently>

    my-other-api-project:
      image: ${DOCKER_REGISTRY-}my-other-api-project
      build:
        context: ../my-other-api-project/    <-- Or whatever the relative path is to your other project
        dockerfile: my-other-api-project/Dockerfile
      ports:
          - <your port mappings>
      depends_on:
        - some-mongo
        - some-rabbit

    some-rabbit:
      <as you have it currently>

    some-mongo:
      <as you have it currently>
like image 108
swatsonpicken Avatar answered Jul 22 '26 14:07

swatsonpicken