Kit
Kit

Reputation: 283

/bin/sh: 1: composer: not found

I am trying to build a 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

But when i run the build command it says:

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

But when I type just composer it is properly displaying the information I guess the problem is with the command:

RUN composer install

Here I am using Ubuntu 14.04

Upvotes: 4

Views: 18821

Answers (1)

Robert
Robert

Reputation: 36893

As the Stacktrace says, install composer before running composer command.

I've added these lines:

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

So your Dockerfile will be:

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

Upvotes: 3

Related Questions