将Docker容器中的webpack-dev-server与主机连接起来 [英] Connecting webpack-dev-server inside a Docker container from the host

查看:520
本文介绍了将Docker容器中的webpack-dev-server与主机连接起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Docker容器(node:4.2.1)中运行一个webpack-dev-server应用程序。如果我尝试从容器内连接到服务器端口 - 它可以正常工作。然而,尝试从主机连接它导致重置连接(端口当然是公布的)。如何修复?

解决方案

此问题不是docker问题。



将--host = 0.0.0.0添加到您的webpack命令。



您需要连接到您的页面像这样:



http:/ /host:port/webpack-dev-server/index.html



查看 iframe模式


I'm running a webpack-dev-server application inside a Docker container (node:4.2.1). If I try to connect to the server port from within the container - it works fine. However, trying to connect it from the host computer results in reset connection (the port is published, of course). How can I fix it?

解决方案

This issue is not a docker problem.

Add --host=0.0.0.0 to your webpack command.

You need to connect to your page like this:

http://host:port/webpack-dev-server/index.html

Look to the iframe mode

这篇关于将Docker容器中的webpack-dev-server与主机连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆