Docker: How to curl local server running on host machine from within a docker container

On my host machine, I have a server running on nginx. It is not dockerized and not accessible to the outside world, it is simply used for local dev environment.

I would like to be able to access it from within a docker container.

  • Network timeout..cannot pull images
  • Jenkins docker missing some binaries
  • Are docker-hosted databases somehow exempt from backup best practices?
  • What execute RUN instruction in exec mode
  • Mulitple Docker Containers on Port 80 with Same Domain
  • Change database location of docker couchdb instance?
  • For example, I’d like to be able to do the following from within my docker container:


    and to see the same output I see when I run the command on my host machine.

    Also, I am using docker-compose.

  • Where are my files / Docker Django Digital Ocean
  • setting gitlab with docker registry error 500
  • Why are container's size and image's size equivalent?
  • Can't connect to MySQL docker container created via docker-compose
  • Graphite installation in a docker container - volume query
  • Docker doesn't download images (connection problems to registry)
  • 2 Solutions collect form web for “Docker: How to curl local server running on host machine from within a docker container”

    It’s probably not routing directly to the host’s network. This question may help.

    I guess your container doesn’t know about your because It is declared in your host’s /etc/host (you said it is a private server)?

    Then you could add the host as extra_host:

          - ""

    The extra_host will add hostname mappings in container’s /etc/host.

    And run your docker-compose.yml replacing HOST_BRIDGE_IP with it’s ip in docker bridge:

    HOST_BRIDGE_IP=$(docker network inspect bridge \
      --format '{{range .IPAM.Config}}{{.Gateway}}{{end}}') \
    && sed -e "s/HOST_BRIDGE_IP/${HOST_BRIDGE_IP}/g" \
    docker-compose.yml | docker-compose --file - up

    This would allow virtual host resolution based on DNS in your server.

    Edit: This seems a bit overkill to me, anyone has a better suggestion?

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