问题描述
jib打包推送到harbor后,启动找不到启动脚本文件 docker-test-1 | exec /entrypoint.sh: no such file or directory entrypoint
原docker-compose配置:
test:image: "xxxxxxxxx"environment:- TZ=Asia/Shanghai- JAVA_OPTS=-Xms3g -Xmx4gprivileged: trueports:- 8080:8080volumes: - /usr/share/fonts:/usr/share/fontscommand: - --spring.profiles.active=${PROFILE} entrypoint: ["/entrypoint.sh"] # 指定入口点脚本 作用:明确指定入口后,脚本才能取到command中的值;restart: alwaysnetworks:- xx
排查思路:
1.分别在源码和容器中查找entrypoint.sh文件。源码中好找,但是容器启不起来,无法进入容器进行查看,解决方法:1.用docker cp命令盲查,确认了确实存在。2.可以把docker打成本地tar解压排查。
2.经过确认文件确实存在,那就是报的错误与实际是有差距的,通过换种写法排查
把 entrypoint: ["/entrypoint.sh"] 分别改为 entrypoint: [ "sh", "-c", "sh /entrypoint.sh" ] 、 entrypoint: [ "sh", "/entrypoint.sh" 进行启动排查
结果报错变了
not foundog-1 | /entrypoint.sh: line 2: docker-by-log-1 | /entrypoint.sh: line 16: syntax error: unexpected word (expecting "do") : not foundog-1 | /entrypoint.sh: line 2: docker-by-log-1 | /entrypoint.sh: line 16: syntax error: unexpected word (expecting "do") : not foundog-1 | /entrypoint.sh: line 2: docker-by-log-1 | /entrypoint.sh: line 16: syntax error: unexpected word (expecting "do") : not foundog-1 | /entrypoint.sh: line 2: docker-by-log-1 | /entrypoint.sh: line 16: syntax error: unexpected word (expecting "do") docker-by-log-1 exited with code 2 docker-by-log-1 exited with code 2 docker-by-log-1 exited with code 2
这个错误就很明显了,报语法错误,但是没人修改过这个文件,大概率是文件格式被编辑器偷偷该过了,经确认确实被改为windowns的格式了,
换成这个问题解决。
但是为啥无缘无故被改没找到原因。不知道是不是idea的问题