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.

  • Can I pass arguments into docker-compose the command config option
  • DotNet build CLI works in terminal, but not in Docker build
  • How can I fix Docker/Mac no space left on device error?
  • Docker 1.12: Multiple replicas, single database
  • how to select options properly for “/bin/bash” when writing a blueprint for cloudify
  • Docker downloaded over 30 ubuntu images
  • ;; 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

  • How to backup MongoDB in a setup with multiple Docker containers?
  • Why is Docker Secrets more secure than environment variables?
  • libicui18n.so.52: cannot open shared object file
  • can't acces mongo from inside docker
  • Add supervisor in php:7-fpm image
  • Can I use docker to provide a simple file overlay over my current system?
  • 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.