sail
Manage Laravel applications with Docker
SYNOPSIS
sail [command] [options] [arguments]
(Invoked via vendor/bin/sail or a shell alias)
php artisan sail [command] [options] [arguments]
(The most common invocation within a Laravel project)
PARAMETERS
up
Starts all defined Docker containers in the background. Options include -d for detached mode.
down
Stops and removes all containers, networks, and volumes defined for the Sail environment. Options include --rmi all to remove images as well.
build
Builds or rebuilds the Docker images for the services. Useful after making changes to the Dockerfile or context.
artisan
Executes a Laravel Artisan command inside the PHP container. Example: sail artisan migrate.
composer
Runs a Composer command inside the PHP container. Example: sail composer require foo/bar.
php
Executes a PHP command or script inside the PHP container. Example: sail php --version.
npm / yarn
Executes an npm or yarn command inside the Node.js container (if configured). Example: sail npm run dev.
test
Runs PHPUnit tests inside the PHP container. Example: sail test --filter PaymentTest.
shell
Opens a bash shell session inside the PHP container, allowing direct interaction with the environment.
logs
Displays log output from the Sail services. Options include -f for follow mode.
stop
Stops running Docker containers without removing them, preserving their state.
DESCRIPTION
Laravel Sail is a light-weight command-line interface (CLI) for interacting with Laravel's default Docker development environment. It provides a simple way to bootstrap and manage a local development stack including services like PHP, Nginx, MySQL, Redis, Mailpit, and more, all running within Docker containers.
The sail command abstracts away complex Docker commands, allowing developers to focus on writing code without deep Docker knowledge. It is typically installed via Composer within a Laravel project and commonly invoked as php artisan sail or through a shell alias. Sail ensures consistency across development environments by enabling execution of various application commands like artisan, composer, npm, php, and test directly within its Docker containers. It significantly streamlines the setup and maintenance of a robust Laravel development environment on Linux, macOS, and Windows (via WSL2).
CAVEATS
Sail requires Docker Desktop (on macOS/Windows) or Docker Engine (on Linux) to be installed and running on the host machine. It is specifically designed for Laravel development and relies on the docker-compose.yml file generated or configured by Laravel. For optimal performance on Windows, it is highly recommended to use WSL2 (Windows Subsystem for Linux 2).
INSTALLATION AND CONFIGURATION
To use Sail, ensure you have Docker installed, then run composer require laravel/sail --dev in your Laravel project. Afterward, execute php artisan sail:install to publish the docker-compose.yml file. You can then configure services like MySQL, PostgreSQL, Redis, etc., by uncommenting them in the generated file.
HISTORY
Laravel Sail was first introduced in August 2020 as part of Laravel 8. Its primary goal was to simplify the Docker setup process for Laravel developers and provide a consistent, official development environment out-of-the-box. It rapidly gained adoption as the preferred local development solution for many Laravel projects, evolving with subsequent Laravel releases to support new features and services.
SEE ALSO
docker(1), docker-compose(1), php(1), composer(1), npm(1)