I've got two docker containers running as part of a docker-compose file, ContainerA is localstack where I'm running a lambda function which is trying to make a HTTP POST request to ContainerB using the below simplified code:
var content = new StringContent("{ "content": "sample" }", Encoding.UTF8, "application/json");
var httpClient = new HttpClient();
var response = await HttpClient.PostAsync("http://ContainerB/Foo", content);
Which raises the following exception:
Request failed - System.Net.Http.HttpRequestException: Name or service not known
If I make the same request from the console of Container A this request succeeds e.g.
curl http://ContainerB/Foo -H "Content-Type: application/json" -d "{ "content": "sample" }"
As this request succeeds from the console I'm fairly confident that it's not a networking issue between my docker containers.