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

  • SSL on dokku+nginx
  • Using MySQL with Spring boot docker image
  • Docker containers gone after a while in CoreOS
  • OpenShift 3.1 - Prevent Docker from caching curl resource
  • How to access ports in docker custom bridge networks
  • Install cURL compiled with OpenSSL and zlib in Dockerfile
  • 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!

  • Cannot mount volume in docker
  • war-file as a part of container or shared folder when running docker
  • Docker: rails executable file not found in $PATH
  • How to define a variable in a Dockerfile?
  • Installing on Ubuntu 14.04LTS
  • lxc-start: Invalid argument - failed to clone
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.