0

This command does not run correctly. give error to execute them

How to write commands with multiple lines in Dockerfile

RUN echo <VirtualHost *> >>  phabricator.conf && \
    echo <Directory "/var/www/html/repository/phabricator/webroot/">' >> phabricator.conf && \
    echo Options All Indexes FollowSymLinks' >>phabricator.conf && \
    echo Order allow,deny' >> phabricator.conf && \
    echo Allow from all' >> phabricator.conf && \
    echo Require all granted' >> phabricator.conf && \
    echo </Directory>' >> phabricator.conf && \
    echo ServerName localhost' >> phabricator.conf && \
    echo DocumentRoot /var/www/html/repository/phabricator/webroot' >> phabricator.conf && \
    echo  >> phabricator.conf && \
    echo RewriteEngine on' >>  phabricator.conf && \
    echo RewriteRule ^/rsrc/(.*)-[L,QSA]  >>  phabricator.conf && \
    echo RewriteRule ^/favicon.ico -[L,QSA]   >>  phabricator.conf && \
    echo RewriteRule ^(.*)$   /index.php?__path__=$1  [B,L,QSA] >>  phabricator.conf && \
    echo '</VirtualHost>' >> phabricator.conf && \
    echo '' >> phabricator.conf && \
  • 1
    Possible duplicate of [How to write commands with multiple lines in Dockerfile while preserving the new lines?](https://stackoverflow.com/questions/33439230/how-to-write-commands-with-multiple-lines-in-dockerfile-while-preserving-the-new) – Cloud Ace Wenyuan Jiang May 17 '19 at 04:30
  • 4
    And the error you're seeing is...? – C. Peck May 17 '19 at 04:31

1 Answers1

3
  1. The last line should not end with && \ - not sure if it is the problem but it sure is a problem.
  2. This is a terrible practice. As you can already see, its hard to debug. Create your files normally, and just COPY them to the image instead of creating them with an awkward chain of shell commands.
DannyB
  • 12,810
  • 5
  • 55
  • 65
  • To have less intermediate images it is better to have less `RUN` steps. But @DannyB is right, for copy files please use `COPY`. – Wie May 17 '19 at 08:24