DEV Community

loading...
Cover image for Create your first Laravel Project on Docker using Laravel Sail

Create your first Laravel Project on Docker using Laravel Sail

chandreshhere profile image Chandresh Singh ・1 min read

There are multiple ways to develop and run Laravel project on your system but here is the easiest way to create your Laravel project on docker using Laravel Sail which is a light weight command line interface for interacting with Laravel's docker configuration.

All you need to do is install docker on your system, you can use either Docker cli or Docker Desktop and rest of the thing are all taken care by Laravel Sail.

Before we start, if you want then you can also watch this tutorial.

Let's Start!

To install Docker Desktop, Click here.

After Docker is installed and running, run the following command to create a new Laravel Project.

curl -s https://laravel.build/example-app | bash
Enter fullscreen mode Exit fullscreen mode

After your project is created, go inside your application directory and start Laravel Sail.

cd example-app

./vendor/bin/sail up
Enter fullscreen mode Exit fullscreen mode

Once done, You can access your application at http://localhost.

You can execute all your commands like this:

./vendor/bin/sail php --version

./vendor/bin/sail node --version

./vendor/bin/sail php artisan list
Enter fullscreen mode Exit fullscreen mode

You can also create an alias for sail if you don't want to type vendor/bin/sail repeatedly.

alias sail='bash vendor/bin/sail'

Enter fullscreen mode Exit fullscreen mode

Then you can execute your commands like this:

sail php --version

sail node --version

sail php artisan list
Enter fullscreen mode Exit fullscreen mode

To stop all your containers, you can type Ctrl+C or you can also use sail down command.

Hope you find this useful.

Discussion (1)

pic
Editor guide
Collapse
sajaddp profile image
Sajad Dehshiri

Hi,
How can I run Laravel on a port other than 80?