How to write commands with multiple lines in Dockerfile while preserving the new lines?

后端 未结 6 1182
情深已故
情深已故 2020-12-07 14:51

I want to write the following RUN command in the Dockerfile. But, docker is not preserving the new lines.

RUN echo \"[repo] \\
name            = YUM Reposito         


        
6条回答
  •  眼角桃花
    2020-12-07 15:44

    I ended up using a combination of the examples listed above since the new line \n did not work with echo.

    RUN printf 'example \n\
    text \n\
    here' >> example.txt
    

    It produces the following, as expected:

    example
    text
    here
    

提交回复
热议问题