Dockerfile CMD命令未执行
我写了这个Dockerfile。它应该构建应用程序,然后将其运行到我创建的容器中,但不起作用。当我使用该图像创建一个容器时,cmd
命令不执行,并且网站未运行。但是,当i exec
容器并手动键入它时,它起作用。
FROM node:16 as builder
WORKDIR /app
COPY ./package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:16
WORKDIR /app
RUN npm install serve
COPY --from=builder /app/build .
CMD ["npx", "serve"]
I wrote this Dockerfile. It should build the app and then run it into the container which I create, but it doesn't work. When I create a container with that image, CMD
commands is not execute and the site is not running. But it works when I exec
the container and type it manually.
FROM node:16 as builder
WORKDIR /app
COPY ./package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:16
WORKDIR /app
RUN npm install serve
COPY --from=builder /app/build .
CMD ["npx", "serve"]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论