复制自定义 nginx 配置后 Docker 镜像未运行

复制自定义 nginx 配置后 Docker 镜像未运行

我有一个DockerFile以下

FROM node:latest AS builder
WORKDIR /app
COPY . .
RUN npm i && npm run prod_build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY ["nginx.conf", "/etc/nginx/conf.d/default.conf"]
EXPOSE 80

ENTRYPOINT ["nginx", "-g", "daemon off;"]

现在自定义 nginx 配置文件nginx.conf在下面

user                            root;
worker_processes                auto;

error_log                       /var/log/nginx/error.log warn;

events {
    worker_connections          1024;
}

http {
    listen       80;
    server_name  10.168.8.59;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

Docker 构建工作正常,但在运行 docker run 命令后,如果我运行docker ps它,它什么也不显示。命令如下

docker build -t po .
docker run --rm -d -p 80:80 po

docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

有人能帮帮我吗?谢谢。

答案1

尝试

docker ps -a

您将看到所有容器,复制容器 ID 并运行:

docker logs CONTAINER ID

相关内容