Laravel with docker-compose

Victor Bolshov
The Startup
Published in
15 min readAug 30, 2019

So, I’ve been using Laravel with docker-compose for development for a while, and now I’m going to make a simple yet functional project skeleton based on a classic laravel/laravel package, and I’m going to document the whole process here.

This article is targeted at PHP devs that use or want to use Laravel, and are also using or willing to use containerized environments. I will also provide some tips & tricks for PHPStorm users, and in a follow-up post I will show how you can deploy this app to Google Kubernetes Engine in Google Cloud.


I will suppose you have docker installed, as well as docker-compose. Some acquaintance with command line, Git and the wonderful Composer package manager is also a must. I will also suppose you have PHP installed locally. I am using a Linux laptop, things are going to be pretty much the same on Mac, and hopefully on Windows but I’m not sure.

Why bother?

Docker & docker-compose have been around for a while already, but are still rapidly growing in terms of adoption and features. For PHP and LAMP devs, containers allow for running different versions of PHP, MySQL, Apache/Nginx for different projects, as well as any other databases, caching servers etc. Running your project with docker-compose makes it isolated from the rest of your machine, and gives your the power to start/stop the whole project with a simple shell command. Read more about benefits of docker-compose for development in this blog post.

Get started

First thing we’ll do is create a Git repository. For that, I will use Gitlab project hosting. As soon as the project is created (I created an empty project, without even a README), I can clone the repository from the terminal. Then I am going to pull everything from laravel/laravel, to my repo:

$ git clone
$ cd laravel-docker
$ git remote add upstream
$ git pull upstream master
$ git push origin master

Now the contents of the project folder should be familiar to you, if you have ever used Laravel.

We’re going to need composer dependencies and perform the basic setup for a Laravel app:

$ composer install --ignore-platform-reqs
$ cp .env.example .env
$ php artisan key:generate

Victor Bolshov
The Startup

I am a PHP programmer, I like opensource software, linux etc.