I have created a dockerFile and docker-compose.yml:
Dockerfile
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
docker-compose.yml
version: "3"
services:
web:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 3021:8000
volumes:
- ./laravel-app:/app
when I execute docker-compose up-- force-recreate-d , laravel app will execute correctly on 127.0.0.1 force-recreate 3021 .
I have seen a lot of docker-composer articles on the web advocating minimizing container, so I would like to ask whether there is any way to rewrite this docker-compose.yml? using the official image of php and composer
. < hr >the following is my test:
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
after completing this docker-compose.yml, I run docker-compose up-- force-recreate-d , however, I did not get any information on 127.0.0.1 force-recreate 3021 .
I then ran docker-compose ps and docker-compose log , and found that container for composer was not started and had the following error information
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 do I modify the subscription?