我有入口shell脚本,它接受参数-a -b.
我有工作的docker-compose.yml文件,我用指令覆盖tomcat的入口点:
entrypoint: /usr/local/tomcat/entrypoint.sh -a param1 -b param2
@H_301_9@
什么是docker run替代品?
docker run --entrypoint "/usr/local/tomcat/entrypoint.sh -a param1 -b param2" tomcat:jre8
@H_301_9@
不起作用
我明白了:
docker: Error response from daemon:
invalid header field value "oci runtime error: container_linux.go:247:
starting container process caused \"exec:
\\\"/usr/local/tomcat/entrypoint.sh -a param1 -b param2\\\":
stat /usr/local/tomcat/entrypoint.sh -a param1 -b param2:
no such file or directory\"\n".
@H_301_9@
供参考:
docker run --entrypoint "/usr/local/tomcat/entrypoint.sh" tomcat:jre8
@H_301_9@
从Docker的角度来看,但显然脚本失败了
最佳答案
这是因为您在命令周围使用了引号.
原文链接:https://www.f2er.com/docker/437118.html当您运行docker run –entrypoint“/usr/local/tomcat/entrypoint.sh -a param1 -b param2”tomcat:jre8 Docker会将这些引号中的任何内容视为单个脚本文件.
从错误中可以看出:
stat /usr/local/tomcat/entrypoint.sh -a param1 -b param2:
no such file or directory\"\n".
@H_301_9@
它正在尝试在运行之前对文件执行stat,因此它知道它是否存在.
将参数放在docker命令末尾的入口点,如下所示:
docker run --entrypoint
你的命令变为:
docker run --entrypoint /usr/local/tomcat/entrypoint.sh tomcat:jre8 -a param1 -b param2
看一下官方文档中的代码片段:
The ENTRYPOINT of an image is similar to a COMMAND because it
specifies what executable to run when the container starts
https://docs.docker.com/engine/reference/run/#/entrypoint-default-command-to-execute-at-runtime