'Running laravel with docker compose

I have installed Laravel (v8) in my local. And now I want to run it from docker. So in the root folder of Laravel, I created two files:

  • docker-compose.yml
  • Dockerfile

this is the content of docker-compose.yml:

version: '3.9'
services:
    laravel:
        build: .

and this is the content of Dockerfile

FROM php:7.4-fpm

COPY . /var/www
COPY . /var/www/html

WORKDIR /var/www

CMD php artisan serve --port=8080
EXPOSE 8080

and then, I run: docker-compose up -d --build after done, I open in browser http://localhost:8080 but the page does not work and shows error_empty_response. when I try run php artisan serve --port=8080 from CLI, and reopen browser.. the page is worked.

what I'm missing? can you help me? thanks before



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source