我在Dockerfile中运行可执行文件时遇到问题。 它包含一个下载' gsoap'来自内部服务的库,然后是以下内容:
ENV PATH="/opt/tools/gsoap/v2.7.12/lnx_x64/bin:${PATH}"
RUN ls -la /opt/tools/gsoap/v2.7.12/lnx_x64/bin
RUN whereis soapcpp2
RUN ["soapcpp2", "-v"]
ls命令返回结果:
drwxr-xr-x 2 root root 4096 Mar 1 17:34 .
drwxr-xr-x 1 root root 4096 Mar 1 17:34 ..
-rwxr-xr-x 1 root root 610652 Mar 1 17:34 soapcpp2
-rwxr-xr-x 1 root root 4270809 Mar 1 17:34 wsdl2h
whereis
也很开心:
soapcpp2: /opt/tools/gsoap/v2.7.12/lnx_x64/bin/soapcpp2
但试图运行它会给出:
standard_init_linux.go:195: exec user process caused "no such file or directory"
这是怎么回事?
如果我改为使用shell形式:
RUN soapcpp2 -v
我得到了
/bin/sh: 1: soapcpp2: not found
咦? whereis
刚刚告诉我很高兴soapcpp2
在PATH上。
答案 0 :(得分:-1)
您需要使用
复制Dockerfile中的文件 ADD
或
COPY
https://docs.docker.com/engine/reference/builder/#add
和
https://docs.docker.com/engine/reference/builder/#copy
顺便说一下,你似乎误用了RUN,也许你的最后一个命令应该是
a
CMD
或
ENTRYPOINT
https://docs.docker.com/engine/reference/builder/#cmd
https://docs.docker.com/engine/reference/builder/#entrypoint
另见
What is the difference between CMD and ENTRYPOINT in a Dockerfile?