How to use docker for old Laravel applications

Dr. Adam Nielsen
1 min readOct 11, 2023

For Laravel applications 8 or higher

sail is directly shipped. From here, I recommend to jump to the perfect documentation of Laravel https://laravel.com/docs/8.x/sail#configuring-a-bash-alias

For Laravel version 5, 6 or 7

There is a package, that contains a minimal docker setup: https://github.com/iwasherefirst2/laravel-docker

You can also checkout this video: https://www.youtube.com/watch?v=MnMMPLEwcxs&ab_channel=Dr.AdamNielsen

When upgrading from Laravel 7 to Laravel 8

I would recommend to install sail package using docker https://laravel.com/docs/8.x/sail#installing-composer-dependencies-for-existing-projects

docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs

This allows you to install sail package, no matter what PHP or composer version you ahve.

Once you have this, I recommend to follow the instructions https://laravel.com/docs/8.x/sail#configuring-a-bash-alias and beyond. From now on, you may always use PHP and composer from sail, so you again don’t need to worry about locally installed versions. Awesome :)

--

--