composer create-project laravel/laravel laravel-app
cd laravel-app
touch .docker/Dockerfile
touch .docker/vhost.conf
Content of Dockerfile:
FROM php:7.3-apache
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app && a2enmod rewrite
Content of vhost.conf:
<VirtualHost *:80>
DocumentRoot /srv/app/public
<Directory "/srv/app/public">
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Building image:
docker build --file .docker/Dockerfile -t laravel-app .
Running container:
docker run --rm -p 8080:80 laravel-app
Source: BitPress