从主机连接 Docker 容器内的 webpack-dev-server [英] Connecting webpack-dev-server inside a Docker container from the host

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

问题描述

我正在 Docker 容器(节点:4.2.1)中运行 webpack-dev-server 应用程序.如果我尝试从容器内连接到服务器端口 - 它工作正常.但是,尝试从主机连接它会导致重置连接(当然,端口已发布).我该如何解决?

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?

推荐答案

这个问题不是 docker 问题.

This issue is not a docker problem.

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

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

查看 iframe 模式

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

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