Docker on Windows: how to connect to container from host using container IP?

前端 未结 2 1785
时光说笑
时光说笑 2020-12-16 02:46

I have

  • Windows 10
  • Docker for Windows V. 1.12.5 Rev. 9503, which does not rely on boot2docker or VirtualBox anymore.

I have a number of

2条回答
  •  旧时难觅i
    2020-12-16 02:53

    you can't. docker is not a virtual machine, and you don't get access to the docker host via IP address.

    see my same question here: https://forums.docker.com/t/access-dockerized-services-via-the-containers-ip-address/21151

    and my realization of how this works, here: https://derickbailey.com/2016/08/29/so-youre-saying-docker-isnt-a-virtual-machine/

    if you need to use the app hosted in the container, from your localhost, expose the port of the app with the -p option of docker run

    docker run -p 8080:8080 image_name

    and then connect to localhost:8080 for that service

提交回复
热议问题