Docker machine / Docker link returns different container IP on Digital Ocean

I created a Droplet on DigitalOcean using Docker machine.

When running two containers and linking them this way from Jenkins:

  • ECS or EB for a single-container application with Docker?
  • Unable to run an Android application in a Docker container with Gitlab-CI
  • Run Jmeter from Jenkins with Docker
  • Ambari-Server on Docker Java install issues
  • Docker - Could not load X509 key pair
  • Upgrading swarm mode cluster
  • /bin/bash/eval "$(docker-machine env deployment)"
    /bin/bash -c "docker run -d -t --name container1 -p 5000:5000 image1"
    /bin/bash -c "docker run -d -t --name container2 -p 5001:5001 --link container1:container1 image2"

    And then docker inspect container1 | grep "IPAddress" I get
    But when I run the Node.js application in container2 which calls process.env.CONTAINER1_PORT_5000_TCP_ADDR it resolves to when I call container2 from its public IP (of the DO droplet) which causes to return No route to host.

    When I exec into container2 and run node process.env.CONTAINER1_PORT_5000_TCP_ADDR it returns

    If I ssh into the host using another user, docker inspect container2 | grep "IPAddress" also returns instead of

    Why does the Node.js application return the wrong IP address whereas running Node.js on the command line returns a different and correct IP address?

    If I run the containers locally on the Jenkins machine without docker-machine and DO, everything works fine.

  • Docker: MySQL refuses host IP unless I restart it manually
  • Snapshot Options When Unable to Set Up LVM
  • Creating user in gerrit through ssh
  • Iptables to forward remote port to local port for local access
  • Dockerfile Script for Amazon AWS
  • Bind data to a db container
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.