How to use pipes(ioredirection) in Dockerfile RUN?

Following line in Dockerfile doesn't work:

RUN git archive master | tar -x -C /path

Error message:

fatal: Not a valid object name
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

How to solve this issue?


How about the following variation: git archive master | tar xf - -C /path git archive master | tar xf - -C /path ?


You can try a sh -c command

RUN sh -c 'git archive master | tar -x -C /path'

If not, you can include that command in a script, COPY the script and RUN it.


It looks like the issue is actually with your git repository (or the directory your RUN is executing in):

fatal: Not a valid object name

This error is coming from git and suggests that there's no branch named master .

链接地址: http://www.djcxy.com/p/26476.html

上一篇: SignalR与消息背板

下一篇: 如何在Dockerfile RUN中使用管道(ioredirection)?