Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 798
Rob L Avatar asked May 25 '15 15:05

Rob L


People also ask

How do I use CAT file in Dockerfile?

Run docker build to create a docker image with tag service (call it v1) Change a file(say prod. json ) that required the 3rd step in the Dockerfile to rerun (thus failing the cache) Run docker build to create docker image with tag service (call it v2)

Can I have ENTRYPOINT and CMD in Dockerfile?

#6 Using ENTRYPOINT with CMD Still, they both can be used in your Docker file. There are many such cases where we can use both ENTRYPOINT and CMD. The thing is that you will have to define the executable with the ENTRYPOINT and the default parameters using the CMD command. Maintain them in exec form at all times.

How do I create a Run command in Dockerfile?

The basic syntax for the command is: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] You can run containers from locally stored Docker images. If you use an image that is not on your system, the software pulls it from the online registry.


1 Answers

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.

like image 166
VonC Avatar answered Oct 25 '22 19:10

VonC