Skip to content

Communicating with localhost from a Docker Container

I have been looking a lot at Docker recently.

At my Job we are about to start a new project using Microservices and plan to run Visual Studio Solution Projects on Docker. As part of the investigation work, I as trying to setup Docker in the Visual Studio Project Files but was hitting issues.

We are currently run RabbitMq and MSSql Server Databases as local installs on our Developer workstations. Obviously at some point we would look to containerize these services but for now I wanted the Docker Containers to run and communicate with the locally installed RabbitMQ and MSSQl Server Database.

Assuming you are using localhost to communicate to RabbitMq and MSSQL Server

The solution is to replace localhost with

host.docker.internal

and include the port number

// for RabbitMq
host.docker.internal:5672

Posted in Developing on Docker