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 is the gitub repository if you need to see the docker-compose.yml file or anything else.
You can use docker run to create a container and execute PHP. You just need to add some volumes to the container. These volumes should include the paths to your code.
Installation PHP composer on Windows:Step 1: Navigate to the official composer website. Step 2: Then click on the Download button. Step 3: Then click on the Composer-Setup.exe & download the file. Step 4: Then click on “Install for all users”.
Installation - Windows# This is the easiest way to get Composer set up on your machine. Download and run Composer-Setup.exe. It will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line. Note: Close your current terminal.
In Dockerfile :
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With