gpt4 book ai didi

laravel -/bin/sh:1: Composer :找不到

转载 作者:行者123 更新时间:2023-12-02 19:36:08 25 4
gpt4 key购买 nike

我正在尝试构建一个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

但是当我只输入 Composer 时,它会正确显示信息
我想问题出在命令:
RUN composer install

在这里我正在使用Ubuntu 14.04

最佳答案

正如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

关于laravel -/bin/sh:1: Composer :找不到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44953756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com