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

  • What is the proper command to restart a Dokku app from SSH?
  • Docker container curl to web
  • Is there a straight way to get html response from a unix socket in Go (like curl does)?
  • How can I build an image using Dockerfile which is on my git repository?
  • how to create a volume in docker with filesystem?
  • Post a Json file to elasticsearch running on Docker, Kitematic on Windows 10
  • 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!

  • Storing secret env variables as separate data container in Docker
  • Disable access to LAN from docker container
  • Docker run container on different port
  • “debconf: delaying package configuration, since apt-utils is not installed” :> google notebooks bash error
  • I need to run twice docker-compose to not have errors
  • How to scale a NodeJS stateful application
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.