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

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

nslookup mycontainername 127.0.0.11

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

  • Call Docker API without docker daemon
  • Openshift node fails to start
  • error running docker inside docker
  • Using Docker Compose to connect to mysql running in another container
  • Docker version 1.13.1, Docker Swarm, jwilder/nginx-proxy will not start as a docker service
  • Why docker exec is killing nohup process on exit?
  • ;; 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

  • need help in Docker Daemon authentication and authorization
  • NFS Server on OSX - squash options
  • How to install ffmpeg for ubuntu using command line?
  • Interactive shell using Docker Compose
  • Why does Dockerfile RUN print echo options?
  • How to create and run docker container with new user other than root?
  • 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 172.25.0.0/16 isolated_nw
    docker network connect isolated_nw mycontainername
    

    And see if you can use 127.0.0.11 (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.