Reputation: 1719
I want to run laravel at docker, so I create a docker-compose.yml like following:
version: '3'
services:
web:
image: my-laravel-image
ports:
- 3021:8000
volumes:
- ./laravel-app:/app
my-laravel-image is create by:
FROM php:7
RUN apt-get update -y && apt-get install -y libmcrypt-dev openssl
RUN docker-php-ext-install pdo mcrypt mbstring
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /app
COPY . /app
CMD php artisan serve --host=0.0.0.0 --port=8000
EXPOSE 8000
When I run docker-compose up --force-recreate -d then access 127.0.0.1:3021 at browser, it works successfully.
Now I want to use php and composer offical image to build two container and connect each other, how to do it?
Following is what I tried:
version: '3'
services:
php:
image: php:7-fpm
ports:
- "3021:8000"
volumes:
- ./laravel-app:/app
composer:
image: composer:latest
volumes:
- ./laravel-app:/app
working_dir: /app
command: ["install","php artisan serve --host=0.0.0.0"]
depends_on:
- php
When I run docker-compose up --force-recreate -d and docker-compose log, it shows following error:
Invalid argument php artisan serve --host=0.0.0.0. Use "composer require php artisan serve --host=0.0.0.0" instead to add packages to your composer.json.
How to fix it?
Upvotes: 0
Views: 87
Reputation: 21
I think the problem is this, you are trying to execute this command:
$ install php artisan serve --host=0.0.0.0
When they should be two command like this:
$ composer install & php artisan serve --host=0.0.0.0
regards.
Upvotes: 1