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
After your project is created, go inside your application directory and start Laravel Sail.
cd example-app
./vendor/bin/sail up
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
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'
Then you can execute your commands like this:
sail php --version
sail node --version
sail php artisan list
To stop all your containers, you can type Ctrl+C or you can also use sail down command.
Hope you find this useful.
Top comments (4)
this command
curl -s https://laravel.build/example-app | bash
start a new laravel project right but with the latest version in laravelso if i want to start a project but with version 8.x or 7.x how i do ?
thanks @Chandresh Singh for this post is very helpful
docker: Error response from daemon: the working directory 'C:/Program Files/Git/opt' is invalid, it needs to be an absolute path.
What should i do
open file docker-compose.yml. find ports: - '${APP_PORT:-80}:80' . change to what you want.