Reputation: 1292
I am new to docker environment and trying to figure out how to make two container communicate with each other.
I have two running containers. Container 1 is having a inference engine running which performs inference on image it receives. Container 1 is listening on port 9001. Container 2 is having the image and wants to send it to Container 1, but is failing saying
port 9001 is already binded to some service
PS When I try to send the image from host to container 1, it works fine, but I cannot understand on how to achieve the same from another container. Any help would be really grateful. Thanks.
Upvotes: 0
Views: 489
Reputation: 11
You can use docker-compose. It will create a bridge network for you when running the command docker-compose up
, Each image defined in the Compose file will get launched in this network automatically.
If you are not using Docker-Compose and running individual container than expose both services port with the host.
docker run -p 9001:9001 image_1
docker run -p host's_port : container_port image_2
Then can to communicate using host IP Like: http://hostip : port
Upvotes: 1