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).

  • Access a docker container on a non standard SSL port
  • Docker custom dns resolve among containers
  • cURL to DropBox using Symfony 3
  • Docker API can’t apply json filters
  • My Meteor App keeps deleting files after rebuild
  • Docker's healthcheck on Windows container and exit code (“||” linux equivalent)
  • 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!

  • Unable to connect to tomcat running in Docker (Connection refused)
  • Docker container logs taking all my disk space
  • Running Gatling from container
  • Building a docker play application with gradle
  • Docker-compose with Django: 'ascii' codec can't decode byte 0xcd in position 7: ordinal not in range(128)
  • Dotnet Antiforgery dll is missing in docker container in OSX
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.