如何处理此转换: echo -e 'FROM busybox\nRUN echo "hello world"' | docker build -

转换为sh (https://github.com/amoffat/sh)语法。

我的问题是args被标记并引用了。因此docker无法将stdin传递到命令的末尾,因为-前后都有单引号。在文档中挖掘,我没有找到支持此方法的方法。

感谢您可以提供的任何帮助(或者,如果您有在子流程中执行此操作的良好示例,那也可以。)!

分析解答

The issue I have is that the args are tokenized and quoted. So docker isn't able to pass stdin onto the end of the command since - has single quotes placed around it.

就像我评论的那样

- isn’t special shell syntax. It should work fine as a normal argument.

不过,依文档来看,这是您的工作方式。使用_in

dockerfile = r"""
FROM busybox
RUN echo "hello world"
"""

docker.build("-", _in=dockerfile)