nginx - 错误后退在 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!
解决方案
采用CMD ["nginx", "-g", "daemon off;"]
此外,您不需要指定命令。CMD 和 EXPOSE 将在基础映像中定义 - 在本例中为 nginx。它们不需要再次定义。
推荐阅读
- airflow - Airflow 1.10.9 未将日志写入 S3
- elasticsearch - 在 Kibana 面板中显示字段的确切值
- amazon-web-services - AWS 根据条件更新所有资源标签
- shell - gfsh 命令不接受带有特殊字符“!”的密码 从 gfsh 控制台
- c# - GetHashCode 方法在 asp.net 核心中为相同的字符串返回不同的值
- javascript - 弹出窗口在错误页面上打开
- python - 如何保存使用 Otsu 过滤器的图像
- javascript - 如何使用 OpenPGP.js 简单地加密字符串?
- cypress - 如何选择在 Cypress 上按住按钮的时间?
- php - 仅由 CSS 和 PHP 使用嵌套无序列表结构的紧凑树