Marc Sloth Eastman
Marc Sloth Eastman

Reputation: 801

How to multi-line echo json from a Dockerfile

When I run docker build . when my docker file is

FROM node:8
RUN echo -e '{
    "a" : "b"
}'

I get

Error response from daemon: Dockerfile parse error line 3: unknown instruction: "A":

Is there a way to do this multiline? I have 10 variable json file I want to enter manually like this, to override some variables.

I have also tried echo -e and printf

Upvotes: 3

Views: 4228

Answers (1)

Adiii
Adiii

Reputation: 60074

You can use \n\ this will keep the file in structure as well, as sometime new line is required in some config file while with \ this it will print in a single line.

FROM node:8
RUN echo '{ \n\
    "a" : "b", \n\
    "c" : "d", \n\
    "e" : "f" \n\
}'

enter image description here

Upvotes: 6

Related Questions