【发布时间】:2020-03-05 12:46:55
【问题描述】:
使用 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!
【问题讨论】:
-
你有
docker run ... bash,这意味着你从一个镜像创建了一个容器,并在其中运行了一个bash进程。您可能需要的是在没有命令名的情况下运行 -
@zerkms - 我使用的图像是从 Dockerfile 创建的,其中包含“CMD [”nginx“]”。但是当没有像“docker run -it private.registry/nginx-cms:001”这样的命令运行时,容器会立即退出。这个镜像如何开始使用 kubectl 部署?
-
如果容器立即存在 - 这意味着
CMD已经退出。
标签: nginx kubernetes dockerfile