Reputation: 161844
In Dockerfile, RUN
has 2 forms:
RUN <command>
(the command is run in a shell - /bin/sh -c - shell form)RUN ["executable", "param1", "param2"]
(exec form)How to encode >
, >>
, <
, &&
||
as a exec form?
This is a very simple dockerfile. I want to rewrite RUN <command>
as exec form.
But I don't know how.
# Dockerfile
FROM ubuntu:14.04
RUN date > /tmp/out && echo 'hello world' >> /tmp/out
CMD cat /tmp/out
Upvotes: 0
Views: 356
Reputation: 10463
According to https://docs.docker.com/engine/reference/builder/#/run:
Unlike the shell form, the exec form does not invoke a command shell. This means that normal shell processing does not happen.
I therefore think that there is no direct way to use these shell-interpreted characters (such as >
, >>
, <
, &&
, ||
) in the exec form.
Upvotes: 6