How to scale Laravel horizontally with Docker

Andrew McLagan
Feb 24, 2016 · 5 min read

Introduction

So, what is docker and why should I be using it?

Why is this important?

Docker containers

Let’s get down to business, show me some examples!

git clone https://github.com/laravel/laravel.git cd laravelcomposer install --prefer-dist
docker-machine create laravel-app-host --driver virtualbox
# /etc/hosts file192.168.99.100 laravel.local # the IP of your docker-machine
docker-compose up
docker-compose stop

Horizontally scaled Laravel, the easy way!

docker-compose scale web=3docker-compose up
<div class="content">
<div class="title">Laravel 5</div>
<h3>{{ gethostname() }}</h3> <!-- paste this line --></div>
docker ps
docker stop laravel_web_2

Closing thoughts

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade