Member-only story

Setting up Docker for Laravel and MySQL application

Wai Hein
2 min readNov 28, 2020

--

This article will briefly show you how to use Docker for Laravel and MySQL application.

Create a .docker folder right inside the project’s root folder.

Then create a Dockerfile file with the following content.

FROM php:7.4.1-apacheUSER rootWORKDIR /var/www/htmlRUN apt-get update && apt-get install -y \libpng-dev \zlib1g-dev \libxml2-dev \libzip-dev \libonig-dev \zip \curl \unzip \&& docker-php-ext-configure gd \&& docker-php-ext-install -j$(nproc) gd \&& docker-php-ext-install pdo_mysql \&& docker-php-ext-install mysqli \&& docker-php-ext-install zip \&& docker-php-source deleteCOPY .docker/vhost.conf /etc/apache2/sites-available/000-default.confRUN curl -sS https://getcomposer.org/installer | php — — install-dir=/usr/local/bin — filename=composerRUN chown -R www-data:www-data /var/www/html \&& a2enmod rewrite

Then create a vhost.conf file with the following content.

--

--

Wai Hein
Wai Hein

Written by Wai Hein

8 x AWS Certified Full-stack | DevOps | Serverless Engineer with over a decade of experience

No responses yet