我正在尝试从dockerfile创建Docker映像,其中我有一个可执行文件。我想为可执行文件设置一些标志,例如:带有静默标志的可执行文件和资源文件的标志。如何在Dockerfile的RUN命令中执行此操作?
到目前为止,我已经尝试过:
RUN /bin/bash -c 'PATH/TO/EXECUTABLE -i silent -f ressourceFile.properties'
,
这只会返回非零1的退出代码。
如果我尝试从之前的层启动中间容器,并使用docker exec -it container_id /bin/bash -c 'PATH/TO/EXECUTABLE -i silent -f file.properties'
运行命令。
它给了我
-i: -c: line 0: unexpected EOF while looking for matching `''
-i: -c: line 1: syntax error: unexpected end of file
我尝试将其运行为
RUN 'PATH/TO/EXECUTABLE -i silent -f ressourceFile.properties'
结果相同
我还尝试根据Dockers documentation
将RUN命令转换为exec形式。 RUN ["/bin/bash", "-c", "PATH/TO/EXECUTABLE", "-i", "silent", "-f", "file.properties"]
但是它无法捕获标志。
当前我的dockerfile看起来像这样,带有已编辑的可执行文件:
FROM perl
COPY EXECUTABLE.bin ressourceFile.properties /tmp/
RUN chmod +x /tmp/EXECUTABLE.bin
RUN /bin/bash -c '/tmp/EXECUTABLE.bin -i silent -f /tmp/ressourceFile.properties'
# For debug purposes
CMD ["tail", "-f", "/dev/null"]
预期结果应该是可执行文件在设置了正确的标志的情况下运行,并且正确设置了file.properties文件的路径。希望你们能提供帮助。