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.

  • Docker Timezone in Ubuntu 16.04 Image
  • Should I add the reverse proxy in the same container as the application on docker?
  • Specify docker engine version with docker machine
  • Node npm test to seeded postgres, Docker network container seeing varying results
  • Error running PostgreSQL on Docker-io
  • Silently Installing pecl modules (e.g. pecl_http) Inside a Docker Container?
  • ;; 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

  • Docker read file from local system when container is running
  • Managing remote docker machines from multiple development machines
  • “ImportError: No module named _bsddb” when opening shelve in Docker container
  • Is the 'local' vm required once the swarm cluster has been deployed?
  • Run nano server container on a Raspberry PI 3
  • How to set the container name used for --link option with Docker
  • 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.