/ bin / sh:1:作曲家:找不到

时间:2017-07-06 15:55:57

标签: laravel docker boot2docker

我正在尝试构建一个Dockerfile。

FROM php:7

RUN mkdir -p /home/winpc/test/laravelApp/app
WORKDIR /home/winpc/test/laravelApp/app


COPY composer.json /home/winpc/test/laravelApp/app
RUN composer install

COPY . /home/winpc/test/laravelApp/app

CMD php artisan serve --host=0.0.0.0 --port=8181
EXPOSE 8181

但是当我运行build命令时,它说:

docker build -t lar-app .
/bin/sh: 1: composer: not found
The command '/bin/sh -c composer install' returned a non-zero code: 127

但是当我输入作曲家时,它正确显示信息 我想问题出在命令:

RUN composer install

这里我使用的是Ubuntu 14.04

1 个答案:

答案 0 :(得分:1)

正如Stacktrace所说,在运行composer命令之前安装composer。

我添加了以下这些行:

RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php -- --quiet
RUN mv composer.phar /usr/local/bin/composer

所以你的Dockerfile将是:

FROM php:7

# Install composer:
RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php -- --quiet
RUN mv composer.phar /usr/local/bin/composer

RUN mkdir -p /home/winpc/test/laravelApp/app
WORKDIR /home/winpc/test/laravelApp/app

COPY composer.json /home/winpc/test/laravelApp/app
RUN composer install

COPY . /home/winpc/test/laravelApp/app

CMD php artisan serve --host=0.0.0.0 --port=8181
EXPOSE 8181