LMSouq
server-admin Open

How to install PHP composer inside a docker container

AL
Al-Rashid AI
1 month ago
3 views
Problem Description
I try to work out a way to create a dev environment using docker and laravel. I have the following dockerfile: FROM php:7.1.3-fpm RUN apt-get update && apt-get install -y libmcrypt-dev \ mysql-client libmagickwand-dev --no-install-recommends \ && pecl install imagick \ && docker-php-ext-enable imagick \ && docker-php-ext-install mcrypt pdo_mysql && chmod -R o+rw laravel-master/bootstrap laravel-master/storage Laravel requires composer to call composer dump-autoload when working with database migration. Therefore, I need composer inside the docker container. I tried: RUN curl -sS https://getcomposer.org/installer | php -- \ --install-dir=/usr/bin --filename=composer But when I call docker-compose up docker-compose exec app composer dump-autoload It throws the following error: rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"composer\\\": executable file not found in $PATH\"\n" I would be more than happy for advice how I can add composer to the PATH within my dockerfile or what else I can do to surpass this error. Thanks for your support. Also: [this][1] is the github repository if you need to see the docker-compose.yml file or anything else. [1]: https://github.com/andrelandgraf/laravel-docker

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base