Docker for windows: how to access container from dev machine (by ip/dns name)

Questions like seem to be asked but I really don’t get it at all.

I have a window 10 dev machine host with docker for windows installed. Besides others networks it has DockerNAT netwrok with IP

  • Xdebug IP changed when VPN Is active
  • Install Oracle on docker centos container: Insufficient disk space
  • Docker mount from host to remote
  • Granularity of Docker containers
  • docker run --ulimit cpu=10 does not kill java process after timeout
  • run docker under supervisor, can not enable tty error
  • I run some containers with docker-compose:

    version: '2'
            build: .
            container_name: docker_a

    It created some network bla_default, container has IP, ofcource I can not connect to from host – it doesn’t have any netwrok interface for this.

    What should I do to be able to access this container from HOST machine? (by IP) and if possible by some DNS name? What should I add to my docker-compose.yml, how to configure netwroks?

    For me it should be something basic, but I really don’t understand how all this stuff works and to access to container from host directly.

  • JVM memory settings in docker container in AWS beanstalk
  • Docker on Cent OS 6 fails to build container after switching to different container directory
  • Using a PostgreSQL database with Docker and Flask, how does it work?
  • Failed to load OSETUP.dll when installing Excel in Windows docker container
  • Docker ps -a doesn't show a stopped mysql client running container
  • Docker for development - Watch/Auto build?
  • 2 Solutions collect form web for “Docker for windows: how to access container from dev machine (by ip/dns name)”

    The easiest option is port mapping:

    just add

        - "8080:80"

    to the service definition in compose. If your service listens on port 80, requests to localhost:8080 on your host will be forwarded to the container. (I’m using docker machine, so my docker host is another IP, but I think localhost is how docker for windows appears)

    Treating the service as a single process listening on one (or a few) ports has worked best for me, but if you want to start reading about networking options, here are some places to dig in:
    Docker’s official page on networking – a very high level introduction, with most of the detail on the default bridge behavior.
    More information on network layout within a docker host
    Host mode is kind of mysterious, and I’m curious if it works similarly on windows.

    Allow access to internal docker networks from dev machine:

    route /P add MASK

    Then use this to enable DNS discovery.

    > docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock --net bridge -p 53:53/udp aacebedo/dnsdock:latest-amd64
    > add as DNS server on dev machine
    > Use labels described in docs to have pretty dns names for containers

    So the answer on the original question:
    Oh, this not actual.


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