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:

  • Installing Java on docker in docker image
  • docker-machine ssh command for mongodump
  • Building a docker play application with gradle
  • Vagrant with Docker Provider fails with rsync over ssh
  • How to determine the Docker image ID for a tag via Docker Hub API?
  • Tutum HAProxy Docker Virtual Host forward to entry point path
  • /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 compose wordpress plugins
  • How to change dockerd parameters with systemd? [duplicate]
  • Restarting host from docker container
  • Docker Websocket Attaching in NodejS
  • How do I link and scale multiple docker containers?
  • How to setup multiple docker containers for multiple developers on the same host?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.