How can I forward localhost port on my container to localhost on my host?

前端 未结 4 1643
遇见更好的自我
遇见更好的自我 2020-12-05 13:39

I have a daemon on my host running on some port (i.e. 8008) and my code normally interacts with the daemon by contacting localhost:8008 for instance.

I\'ve now conta

4条回答
  •  离开以前
    2020-12-05 13:46

    After checked the answers and did some investigation, I believe there are 2 ways of doing that and these 2 only work in Linux environment.

    The first is in this post How to access host port from docker container

    The second should be set your --network=host when you docker run or docker container create. In this case, your docker will use the same network interface you use in Mac.

    However, both ways above cannot be used in Mac, so I think it is not possible to forward from the container to host in Mac environment. Correct me if I am wrong.

提交回复
热议问题