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:

  • Docker-compose daemon exiting
  • Permission Issue in Docker container for Symfony2
  • IBM Bluemix: Not able to mount the MongoDB container “/data/db” on the Bluemix host volume
  • Docker compose with two files
  • How to get Docker work properly from within the msys2 bash?
  • Confusion on using docker-compose volumes to serve django static files
  • /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.

  • Use of container docker as a proxy for CF app to get public IP
  • How to build a cassandra cluster with docker on a windows machine?
  • docker build taking too much time in aws ecs
  • Why docker-storage-setup doesn't create thin pool for overlayfs driver?
  • Get version of the docker base image used to build an image
  • NodeJS in Docker - cannot access node_modules
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.