Jas*_*ane 38 docker reactjs create-react-app
I am trying to start a Docker container with a react project, the project is created using npm init react-app.
This is my docker file
# Specify a base image
FROM node:alpine
WORKDIR /usr/app
# Install some depenendencies
COPY ./package.json ./
RUN npm install
COPY ./ ./
# Default command
CMD ["npm", "run", "start"]
Run Code Online (Sandbox Code Playgroud)
Docker build . creates an image successfully (with a lot of npm warnings) and then when I run Docker run <image> this is the output in my terminal
> mytest@0.1.0 start /usr/app
> react-scripts start
? ?wds?: Project is running at http://172.17.0.2/
? ?wds?: webpack output is served from
? ?wds?: Content not from webpack is served from /usr/app/public
? ?wds?: 404s will fallback to /
Starting the development server...
Run Code Online (Sandbox Code Playgroud)
Soon as it hits Starting the development server... it stops running in my terminal. If I check Docker ps I can see no containers are running, if I run Docker ps -a I can see a container was started up and then exited immediately.
Docker logs shows the terminal output above, anybody run into this situation? Its only with my npm init react-app project, my other nodejs + express projects run fine with the exact same docker file
Ram*_*usa 45
我尝试降级,但没有奏效。对我有用的是docker-compose我添加的反应应用程序部门的文件:
stdin_open: true
Run Code Online (Sandbox Code Playgroud)
此处也建议使用此解决方案:github 上的问题
我解决了这个问题。在 package.json 中将 "react-scripts": "3.4.1" 替换为 "react-scripts": "3.4.0"
然后重建图像,它的工作原理!他们搞砸了 react-scripts": "3.4.1" 只需使用 3.4.0 版
| 归档时间: |
|
| 查看次数: |
10429 次 |
| 最近记录: |