ERROR: Dockerfile parse error line 4: unknown instruction: PHP7

ERROR: Dockerfile parse error line 4: unknown instruction: PHP7

我有一个 dockerfile

FROM alpine:3.7

RUN apk --no-cache add
php7
php7-fpm
php7-pdo
php7-pdo_mysql
php7-mcrypt
php7-mbstring
php7-xml
php7-openssl
php7-json
php7-phar
php7-zip
php7-dom
php7-session
php7-zlib &&
php7 -r "copy('http://getcomposer.org/installer', 'composer-setup.php');" &&
php7 composer-setup.php --install-dir=/usr/bin --filename=composer &&
php7 -r "unlink('composer-setup.php');" &&
ln -sf /usr/bin/php7 /usr/bin/php &&
ln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini

RUN set -x
&& addgroup -g 82 -S www-data
&& adduser -u 82 -D -S -G www-data www-data

COPY . /src
ADD .env.example /src/.env
WORKDIR /src
RUN ["/bin/sh", "-c"," php artisan key:generate"]
RUN chmod -R 777 storage
CMD php artisan serve --host=0.0.0.0

虽然 运行 它,但我一直在

Creating network "portal-modules_default" with the default driver                                                                  
Building fingerprinting                                                                                                            
> ERROR: Dockerfile parse error line 4: unknown instruction: PHP7                                                                    
⚡️  portal-modules 

ERROR: Dockerfile parse error line 4: unknown instruction: PHP7

关于如何解决这个问题的任何提示?

我需要把 & 放在某个地方来连接命令吗?

问题是:

RUN apk --no-cache add
php7
php7-fpm
php7-pdo
php7-pdo_mysql
php7-mcrypt
php7-mbstring
php7-xml
php7-openssl
php7-json
php7-phar
php7-zip
php7-dom
php7-session
php7-zlib &&
php7 -r "copy('http://getcomposer.org/installer', 'composer-setup.php');" &&
php7 composer-setup.php --install-dir=/usr/bin --filename=composer &&
php7 -r "unlink('composer-setup.php');" &&
ln -sf /usr/bin/php7 /usr/bin/php &&
ln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini

如果要在多行中编写命令,请使用反斜杠(\) 符号:

RUN apk --no-cache add \
    php7 \
    php7-fpm \
    php7-pdo \
    php7-pdo_mysql \
    php7-mcrypt \
    php7-mbstring \
    php7-xml \
    php7-openssl \
    php7-json \
    php7-phar \
    php7-zip \
    php7-dom \
    php7-session \
    php7-zlib && \
    php7 -r "copy('http://getcomposer.org/installer', 'composer-setup.php');" && \
    php7 composer-setup.php --install-dir=/usr/bin --filename=composer && \
    php7 -r "unlink('composer-setup.php');" && \
    ln -sf /usr/bin/php7 /usr/bin/php && \
    ln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini

每行换行时加反斜杠。

有用link:https://docs.docker.com/develop/develop-images/dockerfile_best-practices/