【发布时间】:2022-01-03 01:12:23
【问题描述】:
我的 React 应用程序没有在 Docker for Windows 上使用 docker-compose 和 WSL2 重新加载。
docker-compose.yml
frontend:
container_name: frontend
build:
context: ./github-finder-app
volumes:
- '/var/app/node_modules'
- './github-finder-app:/var/app'
ports:
- 3000:3000
stdin_open: true
environment:
- CHOKIDAR_USEPOLLING=true
command: npm start
Dockerfile
FROM node:14.9
WORKDIR /var/app
COPY . .
RUN npm install --only=prod
EXPOSE 3000
到目前为止,我一直在尝试使用 Chokidar、.env 文件和不同的 Dockerfile。
【问题讨论】:
-
你可以试试这里提到的解决方案stackoverflow.com/questions/61576659/…认为环境变量的提及方式不同。
-
我有错误:
services.frontend.environment.0 must be a string -
从所提供的代码 sn-p 中,您将其作为布尔值传递。您可以尝试传递我之前评论中提供的链接中提到的字符串吗?环境:CHOKIDAR_USEPOLLING:“真”
标签: reactjs docker webpack docker-compose dockerfile