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

  • Accessing Docker Node API from Digital Ocean
  • cURL to DropBox using Symfony 3
  • service docker start fails (daemon is not a docker command)
  • Using Docker Engine API to execute command in an existing container
  • My Meteor App keeps deleting files after rebuild
  • Restarting containers after docker-machine host is rebooted
  • 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!

  • How to mount external volume for mongoDB using docker-compose and docker-machine
  • How does docker manage hashes for forking of docker images?
  • View dockerFile associated with tag
  • How to configure spring interceptor to get called with every request
  • How to use Haskell Stack with Docker Compose?
  • Specify Docker date on image build or container start without affecting host
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.