kev
kev

Reputation: 161844

How to encode an arbitrary command to a exec form in Dockerfile?

In Dockerfile, RUN has 2 forms:

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

Answers (1)

reto
reto

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

Related Questions