Docker and React configuration [WINDOWS 10 home and VSCODE]



我无法使用 docker-compose up command.
docker-compose up => 获取 React 的所有路由,这只允许我访问 react 应用程序的默认路由。此外,我可以使用本地 npm run 命令成功访问它们。我是否遗漏了什么,可能在集装箱化中? 任何想法为什么会发生这种情况?

这是我的 .yml 文件

version: "3"
services: 
client:
build:
context: ./client
dockerfile: Dockerfile
image: fc-client-app
restart: always
ports: 
- "80:80"
volumes:
- /client-app/node_modules
- .:/client-app
depends_on: 
- "server"
server:
build:
context: ./server
dockerfile: Dockerfile
image: fc-server-app
ports: 
- "8080:8080"
volumes:
- /server-app/node_modules
- .:/server-app

问题出在客户端服务上。

这是我的客户端服务的Docker文件:-

FROM node:lts
WORKDIR /usr/src/client-app
ENV PATH /usr/src/client-app/node_modules/.bin:$PATH
COPY package*.json ./
RUN npm install
RUN npm install react-scripts@3.4.1 -g 
COPY . .
EXPOSE 80
CMD ["npm", "start"]

您在客户端 docker 文件中公开了端口 8080,但 docker-compose 中为客户端服务指定的端口为 80。8080 用于您的服务器服务。请尝试更改 docker 文件中的客户端端口。

最新更新