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 logs
和 kubectl describe pod
等命令来做 troubleshooting
我犯的错误就是没有弄清楚 ENTRYPOINT
和 CMD
的区别和用法,如果想要让在容器被创建之前执行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 "$@"