[英]Docker: Error: Cannot find module /app/src/myapp.js
When I build my container it seems to compile without any issues using:当我构建我的容器时,它似乎可以使用以下方法进行编译而没有任何问题:
docker build -t mycompany:1.0.0 .
When I check docker images
the container displays.当我检查docker images
,容器会显示。
When I try to host it locally using当我尝试使用本地托管它时
docker run -p 8081:8081 -it mycompany:1.0.0
it returns an error saying:它返回一个错误说:
Error: Cannot find module '/app/src/myapp.js
I feel like it shouldn't be this complicated.我觉得不应该这么复杂。 Here is my docker file:这是我的 docker 文件:
FROM node:10
WORKDIR /app/src
COPY package.json /app
RUN npm install
COPY . /app
CMD node myapp.js
EXPOSE 8081
What is off?什么是关闭?
You can see from the error itself , you are not copying anything inside /app/src.您可以从错误本身看到,您没有在 /app/src 中复制任何内容。 Your both COPY command's destination is /app.您的两个 COPY 命令的目的地都是 /app。 You need to place myapp.js inside /app/src.您需要将 myapp.js 放在 /app/src 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.