node.js - 浏览 Docker 托管的应用程序时出现 ERR_CONNECTION_REFUSED
问题描述
我开发了一个 Node.js 应用程序。我可以使用它运行它node bin/www
,然后我可以在浏览器上通过http://localhost:3000/访问它。
然后我将它 dockerized,但尝试在浏览器上访问它http://localhost:3000/显示 ERR_CONNECTION_REFUSED。
我可以通过运行看到容器docker ps
:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
9301a87c47af hello-express "/bin/sh -c 'node bi…" 4 minutes ago Up 2 minutes 0.0.0.0:3000->3000
/tcp admiring_torvalds
Dockerfile:
FROM node:7
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD node bin/www
EXPOSE 3000
我在 Windows 10 上工作并使用 Docker Toolbox。
解决方案
In Docker Toolbox, a container is implemented as a VM. This VM has a different IP address. I used Kinematic (a GUI for Docker Toolbox) to find the IP address of the VM and then reached it on the browser via its IP rather than localhost.
推荐阅读
- laravel - Laravel 5.7 雄辩的查询,带有多个 where 和一个 whereNotIn
- vb6 - 不推荐使用 MSDatashape
- video - amp-story 视频未显示全图(宽度、高度问题)
- go - 使用 AWS SDK for Go 中的 S3 客户端,无需凭证
- c# - 在用户通过身份验证之前,如何隐藏我的导航栏?
- angular - 角度路由 - 在根路由级别激活默认子路由
- single-sign-on - 为什么在设置基于 SAML 的 SSO 时需要 IdP 证书指纹
- amazon-web-services - 基于 SQS ApproximateNumberOfMessagesVisible 自动扩展 Fargate 服务
- python - Pandas 系列追加返回 NaN 值
- r - SpaatioTemporal 包错误:“'LUR.in' 的长度与时间趋势的数量不匹配。”