当我尝试在Docker镜像中构建mxnet时,我收到以下消息:
Step 14/16 : RUN ["/bin/bash", "-c", "cd /workspace/Project/mxnet"]
---> Running in c9337d66ee5e /workspace/Project/mxnet
Removing intermediate container c9337d66ee5e
---> b92ad26e0218 Step 15/16 : RUN ["/bin/bash", "-c", "make"]
---> Running in 653a66e430b2 make:
*** No targets specified and no makefile found.
Stop. The command '/bin/bash -c make' returned a non-zero code: 2
任何建议?
答案 0 :(得分:0)
的问题
Step 15/16 : RUN ["/bin/bash", "-c", "make"]
[…] The command '/bin/bash -c make' returned a non-zero code: 2
可能来自事先运行此命令的事实:
Step 14/16 : RUN ["/bin/bash", "-c", "cd /workspace/Project/mxnet"]
这是Docker中的典型错误模式。
总而言之,每个Docker RUN命令都在子shell中运行,所以如果你这样做
RUN ["/bin/bash", "-c", "cd /workspace/Project/mxnet"]
RUN other commands
其他命令不受目录更改的影响。
要解决此问题,您可以:
用
替换两行RUN cd /workspace/Project/mxnet && other commands
或(首选解决方案)用
替换两行WORKDIR /workspace/Project/mxnet
RUN other commands
解决方案2更具惯用性,请注意
WORKDIR /dir
RUN some command
可以在语义上看作命令
的等价物mkdir -p /dir && cd /dir && /bin/sh -c "some command"