这是一个PATH相关的问题和配置文件。当您使用sh -c
或bash -c
时,配置文件未加载。但是当您使用bash -lc
时,它意味着加载配置文件并执行命令。现在您的配置文件可能有必要的路径设置来运行此命令。
编辑-1
因此,与原来的答案的问题是,它不能正常工作。当我们有
ENTRYPOINT ["/bin/bash", "-lc", "ocp-indent"]
CMD ["--help"]
它最终转化为/bin/bash -lc ocp-indent --help
,而它的工作,我们需要/bin/bash -lc "ocp-indent --help"
。这不能通过在入口点使用命令直接完成。所以,我们需要一个新的entrypoint.sh
文件
#!/bin/sh -l
ocp-indent "[email protected]"
确保chmod +x entrypoint.sh
主机。并更新Dockerfile以下
FROM ocaml/opam
WORKDIR /workdir
RUN opam init --auto-setup
RUN opam install --yes ocp-indent
SHELL ["/bin/sh", "-lc"]
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["--help"]
构建之后,并运行它的工作原理
$ docker run f76dda33092a
NAME
ocp-indent - Automatic indentation of OCaml source files
SYNOPSIS
原来的答复
您可以使用以下命令
docker run -it --entrypoint "/bin/sh" <image id> env
docker run -it --entrypoint "/bin/sh -l" <image id> env
docker run -it --entrypoint "/bin/bash" <image id> env
docker run -it --entrypoint "/bin/bash -l" <image id> env
方便地测试这两个之间的区别
现在,无论你有没有可以rect路径,或者只有在使用-l
标志时才会出现。在这种情况下,你可以改变你的泊坞窗映像的默认外壳下面
FROM ocaml/opam
WORKDIR /workdir
RUN opam init --auto-setup
RUN opam install --yes ocp-indent
SHELL ["/bin/bash", "-lc"]
RUN ocp-indent --help
ENTRYPOINT ["/bin/bash", "-lc", "ocp-indent"]
CMD ["--help"]
我不知道为什么它会如果'run'工程是必要的,但你试过指定为'ocp-完整路径indent'? – kichik
如何? '运行<路径到ocp-indent.exe>'? – user1795832
是的。它可能在'/ bin'或'/ usr/bin'中。 – kichik