How do I resolve hostnames to Docker containers from the host?

I understand Docker runs a magical dns on, so I figured I’d try

nslookup mycontainername

where mycontainername is, of course, the name of the container I’m trying to access. However, that timed out.

  • How to restore a mongo Docker container on the Mac
  • Docker on Raspberry Pi 2: Could not reach any registry endpoint
  • install/access executable for existing docker container
  • configure Angular 2 Webpack App in Docker container environment specific
  • Using a buildroot distro as a docker *host*
  • Not able to install the gem “rmagick” with docker
  • ;; connection timed out; no servers could be reached

    What am I doing wrong? I’m on Docker 1.10.3. If it helps, I’m pulling up a bunch of containers using docker-compose 1.6.2.

    EDIT This is a duplicate of Docker 1.10 access a container by it's hostname from a host machine

  • Datadog count metric dropping with multiple containers
  • docker: executable file not found in $PATH
  • Windows 10: How to track 'docker pull' traffic calls using fiddler
  • How do I deploy this docker app on digital ocean?
  • Reduce SYS_ADMIN Linux capabilities
  • Connect to another container using Docker compose
  • One Solution collect form web for “How do I resolve hostnames to Docker containers from the host?”

    In the documentation it implies that this only works if you’ve explicitly created a network and attached the containers to them. Try something like:

    docker network create -d bridge --subnet isolated_nw
    docker network connect isolated_nw mycontainername

    And see if you can use (worked for me on version 1.10.3)

    For more information see this ticket.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.