kubernetes 创建 Pod 失败 (Bug)

Bug 1

问题描述

standard_init_linux.go:178: exec user process caused “exec format error”

解决方法

在 entry_point.sh 文件中的头部加上 #!/bin/bash 就好

Bug 2

问题描述

创建Pod失败,并且通过 kubectl describe 查看错误信息:
Kubernetes Pod fails with CrashLoopBackOff

解决方法

The issue caused by the docker container which exits as soon as the “start” process finishes. i added a command that runs forever and it worked. This issue mentioned here

就是Pod刚一创建就结束了,可以检查dockerfile是否正确书写. 然后建议通过 kubectl logskubectl describe pod 等命令来做 troubleshooting

我犯的错误就是没有弄清楚 ENTRYPOINTCMD 的区别和用法,如果想要让在容器被创建之前执行Entrypoint的内容,然后再执行CMD的内容,需要在Entrypoint的结尾加上

exec "$@"

具体可参考博客:blog.51cto.com/8869176/2082584

以OperationTrident的后台程序为例,dockerfile:

FROM mono
MAINTAINER w2w
RUN mkdir /app
COPY . /app

RUN msbuild /app/OperationTridentBackEnd.sln /t:Build /p:Configuration=Release

COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 8000
# CMD ["/bin/bash", "-c", "\"while true;do echo hello docker; sleep 1; done\""]
# CMD ["/bin/echo", "this is a echo test"]
CMD ["mono", "/app/OperationTridentBackEnd/bin/Release/OperationTridentBackEnd.exe"]

docker-entrypoint.sh:

#!/bin/bash
# replace config with env variable
sed -i "s/127.0.0.1/$MYSQL_SERVICE_HOST/" /app/OperationTridentBackEnd/bin/Release/OperationTridentBackEnd.exe.config 
sed -i "s/3306/$MYSQL_SERVICE_PORT/" /app/OperationTridentBackEnd/bin/Release/OperationTridentBackEnd.exe.config

exec "$@"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值