Fix IP for Docker

356 views Asked by At

I have several Microservices that each have a separate Docker container. It is in CS 2017, Docker Desktop for Windows. These services are talking each other using IP address that Docker assigned. The problem is that in Debug mode the project in Visual studio every time I change something and build the project the IP of docker is changing so I have to go through the code and change the IP, is there anyway to have a fix the IP or use static IP?

1

There are 1 answers

2
Tarun Lalwani On

You should create a network for your project

docker network create myproject

Then when you run you docker containers give each of them a name

docker run --name service1 --net myproject service1image

Now other services also using same method. Now each service can reach other using the the name