Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 669
Marc Sloth Eastman Avatar asked Jan 29 '26 19:01

Marc Sloth Eastman


1 Answers

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

like image 61
Adiii Avatar answered Jan 31 '26 23:01

Adiii