我有一个angular 17项目,我想把它停靠.我已经构建了我的镜像,当我试图使用docker run -dit --name <container name> <imagename>
运行容器时,容器立即退出.当我运行docker ps
时,容器不会出现.
文档文件:
# Use node image as builder
FROM node:18.14 AS builder
# Set working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the container
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build --prod
# Use nginx image for serving the application
FROM nginx:latest
# Copy built application files from builder stage to nginx directory
COPY --from=builder /app/dist/project /usr/share/nginx/html
# Expose port 80 for nginx
EXPOSE 80
# Start nginx in foreground
CMD ["nginx", "-g", "daemon off;"]
我注意到我的图像无法在docker桌面中分析,如以下截图所示: Docker Desktop