简体   繁体   English

Containerzied React 应用程序和 NGINX 不在我想要的本地主机端口上提供服务

[英]Containerzied React app and NGINX not serving on the localhost port I want

I have a containerized React app that I'm trying to test out building with webpack and serving the static generated files with the NGINX image, but it's not being displayed on the port I want locally.我有一个容器化的 React 应用程序,我正在尝试测试使用 webpack 构建并使用 NGINX 图像提供静态生成的文件,但它没有显示在我想要的本地端口上。 My WebPack file is outputting files in to a directory called dist so as you can see in my Dockerfile I'm going in to that directory and copying my files to the usr/share/nginx/html directory.我的 WebPack 文件将文件输出到一个名为 dist 的目录中,因此您可以在我的 Dockerfile 中看到我将进入该目录并将我的文件复制到 usr/share/nginx/html 目录中。 Is there something else I'm missing in this file?这个文件中还有什么我遗漏的吗?
来自 dockerfile 的屏幕截图

Nginx 在端口 80 上提供服务,因此当您运行容器时,您需要在docker run命令中将该端口映射到端口 3000:

docker run -d -p 3000:80 app-image

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Express.js 继续提供静态 index.html(React 应用程序),即使我不想要它 - Express.js keeps serving static index.html (React app) even I do not want it 为什么我可以使用 IP 地址从 React 应用程序调用 api 端口,但当我使用“localhost”时却不能 - Why can I call api port from React app using ip address, but not when I use "localhost" 使用 nginx 在特定位置提供反应应用程序时出现空白页面 - Blank page when serving react app with nginx in a specific location 为 Create-React-App 设置 NGINX 以使用 localhost:3000 - Setting up NGINX to go localhost:3000 for Create-React-App Dockerize React-Django 应用程序并在 Nginx 服务器上提供服务错误:502 错误网关 - Dockerize React-Django App and serving on Nginx server Error : 502 Bad Gateway PM2, 502 Bad gateway, Nginx 同时服务于 React 应用程序和 NodeJS API - PM2, 502 Bad gateway, Nginx serving both React app and NodeJS API 使用 localhost 而不是 localhost:8081 我有 nginx,webpack,反应堆栈如何? - Using localhost instead of localhost:8081 I have nginx, webpack, react stack how? 我想检查用户是否在 React 应用程序中在线? - I want to check if user is online in a React app? 通过 ingress-nginx 作为代理从在 localhost 上运行的 react 应用程序访问 Kubernetes 集群 - Accessing Kubernetes Cluster through ingress-nginx as proxy from react app running on localhost 为什么我的React应用程序将外部URL附加到http:// localhost:/ <port> 而不只是URL本身? - Why does my React app append the external URL to http://localhost:/<port> and not to ONLY the URL itself?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM