我有一个示例React项目,每次运行时
..npp install
..npm run
...
Compiled successfully!
You can now view material-kit-pro-react in the browser.
Local: http://localhost:3000
On Your Network: http://10.0.1.4:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
服务器启动并运行(它使用了react-script);但是,我的目的是对其进行dockerize,并在dockerfile下使用
FROM node:12
USER root
RUN mkdir -p /var/tmp/thermo && chown -R root:root /var/tmp/thermo
WORKDIR /var/tmp/thermo
COPY * ./
RUN npm install
EXPOSE 3000
CMD [ "npm", "run","start"]
我可以成功制作图像,但是当我运行docker文件时,由于该程序存在,因此我看到以下日志n
[root@*****]# docker logs 5edbd29016bd
> material-kit-pro-react@1.9.0 start /var/tmp/thermo
> react-scripts start
Could not find a required file.
Name: index.html
Searched in: /var/tmp/thermo/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! material-kit-pro-react@1.9.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the material-kit-pro-react@1.9.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-07-30T08_03_34_725Z-debug.log
[root@**********8]#
在我的VM上不进行dockerization运行时,我看不到此类错误。
答案 0 :(得分:0)
在您的dockerfile中更改
COPY * ./
到
复制。 ./
然后再次构建它,然后运行,将对其进行修复。