错误在Nginx Pod中退后重新启动失败的容器

使用kubernetes部署nginx映像的简单用例

用于创建映像的Dockerfile。 dockerfile COPY语句中的“ ./build/”是reactjs代码的输出目录(npm run build)。其中只是静态文件。

FROM nginx
COPY ./build/ /usr/share/nginx/html/ 
RUN rm -f /etc/nginx/conf.d/default.conf
COPY ./default.conf /etc/nginx/conf.d/
CMD ["nginx"]
EXPOSE 80 

为什么在nginx部署中出现此错误?错误是“退回重新启动失败的容器”。 手动运行容器,但是nginx没有运行。我可以手动启动Nginx。我是否在Dockerfile或/etc/nginx/conf.d/default.conf文件中缺少任何配置?文件已复制,并且可以在github路径中用作参考。

root@desktop:~/github/nginx-app# docker run -it private.registry.corp/company-dev-poc/nginx-cms:001 bash
root@fc7ebd431ae2:/# service nginx status
[FAIL] nginx is not running ... failed!
tmc19850121 回答:错误在Nginx Pod中退后重新启动失败的容器

使用CMD ["nginx","-g","daemon off;"]

此外,您无需指定命令。 CMD和EXPOSE将在基本映像中定义-在这种情况下为nginx。无需再次定义它们。

本文链接:https://www.f2er.com/3134957.html

大家都在问