cURL from host-to-container works, but from container-to-container does not
Title pretty much says it all, but let me give some context.
I have a MySQL instance running one one container, an API running in another, and a script running in a third. The script hits (or is supposed to hit) the API running in the second. These are all on the same physical machine (on DigitalOcean).
I have the port we’re using (8080) exposed in the Dockerfile for the API, and exposed using
-p 8080:8080 at runtime for the API. I have the script pointing to the API IP correctly.
In other environments (AWS, RaspPI), this setup works fine. But, on DigitalOcean, it’s not working at all. My script’s attempts to hit the database API simply fails.
Strangely enough, cURLing from the host machine to an API endpoint works fine, so the API itself is working. cURLing from inside the script docker container using docker exec, however, leads to a timeout every time – the same problem I’m having from within the script.
My only two guesses are that this has something to do with DigitalOcean configuration settings for their Docker droplet, or that Docker has inter-container communication configuration that I’m missing.
TL;DR: cURL from host machine -> Docker container API works. cURL from Docker container on same machine -> Docker container API does not.
Regardless, if any of you guys want more information, don’t hesitate to ask 🙂 Cheers!