如何在Dockerfile中将任意命令编码为execforms?

在Dockerfile中, RUN有两种forms:

  • RUN <command> (该命令运行在shell – / bin / sh -c – shellforms中)
  • RUN ["executable", "param1", "param2"] (execforms)

如何编码>>><&& || 作为执行forms?


这是一个非常简单的dockerfile。 我想要将RUN <command>重写为execforms。
但我不知道如何。

 # Dockerfile FROM ubuntu:14.04 RUN date > /tmp/out && echo 'hello world' >> /tmp/out CMD cat /tmp/out 

根据https://docs.docker.com/engine/reference/builder/#/run

与shellforms不同,execforms不会调用命令shell。 这意味着正常的shell处理不会发生。

因此,我认为在execforms中没有直接的方式来使用这些shell解释的字符(比如>>><&&|| )。