Docker image run results in executable not found i

2020-05-04 14:38发布

问题:

This is a continuation of a previous question: The command returned a non-zero code: 127. I'm trying to build and run the below Dockerfile for use by others. My original issue was the build failed due to profiles not loading (wonderfully answered in the above question), now I'm trying to get it to run properly.

Here is the Dockerfile I'm currently at, which builds fine now that it has a SHELL step (forgot that the idea is to also use whalebrew in the end for even easier install).

FROM ocaml/opam

SHELL ["/bin/sh", "-lc"]
LABEL io.whalebrew.name 'ocp-indent'
LABEL io.whalebrew.config.working_dir '/workdir'
WORKDIR /workdir

RUN opam init --auto-setup
RUN opam install --yes ocp-indent
RUN ocp-indent --help

ENTRYPOINT ["ocp-indent"]
CMD ["--help"]

I then run it via docker run -it <image id>, but I get an error: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"ocp-indent\": executable file not found in $PATH". As mentioned in the answer of the other question, could create a .sh file for the entrypoint, run a chmod script, and make a few other changes to Dockerfile.

Ultimately I'm trying to make it as easy as possible on people wanting to install this. e.g.: whalebrew install <name> followed by ocp-indent --version should output its version just like that. They shouldn't have to do anything more.

I'm still learning Docker as I go, their docs are actually pretty good but difficult to troubleshoot issues.