How connect two docker containers

Hello. I have two docker containers with .net core app. First container has exposed port 44333 second 44399.
I can get access localy by exposed port to the images in first docker by localhost:44333/getImages and I got all images. But when my second docker invokes this request localhost:44333/getImages there is an error:
System.Net.WebException: Cannot assign requested address Cannot assign requested address
I tried put this two containers in one network but it does not works.

Second container must connect to first container by using service name instead of localhost. Service name act as dns for the given container which should be used to call them.

1 Like