Getting Started With Laravel On Mac Using Docker Desktop and Laravel Sail

By bhagwatchouhan
Getting Started With Laravel On Mac Using Docker Desktop and Laravel Sail

This tutorial provides all the steps required to create the first project in Laravel using Laravel Sail and Docker Desktop on macOS Catalina. Laravel Sail is a lightweight command-line interface that can be used to interact with Laravel's default Docker configuration. Laravel Sail is a built-in solution to run Laravel projects using Docker Desktop. You can also follow How To Install Docker Desktop On Mac.

 

Notes: It's Bandwith Intensive operation for the first time, hence make sure that you are on a good internet connection and also follow How To Install Docker Desktop On Mac to avoid filling your root drive. The Sail's application containers will be built on your machine for the first time.

 

Install Docker Desktop

 

Install Docker Desktop on your Mac system to continue with this tutorial. You can follow How To Install Docker Desktop On Mac. Docker Compose gets installed with the Docker Desktop.

 

Create Laravel Project

 

Launch Terminal and create the Laravel project in your preferred directory using the command as shown below.

 

# Create Project
curl -s "https://laravel.build/helloworl" | bash

 

It will start creating the Laravel project within the current directory as shown in Fig 1.

 

Laravel Sail using Docker Desktop on Mac - Install

Fig 1

 

It will download all the applications and dependencies and shows a success message as shown in Fig 2.

 

Laravel Sail using Docker Desktop on Mac - Install

Fig 2

 

Launch Laravel Project

 

We can launch the newly installed Hello World project in Laravel using Sail using the commands as shown below.

 

cd helloworld

./vendor/bin/sail up

 

It will take some time for the first launch as shown in Fig 3. The subsequent launches will be faster. On successfully launching the required service, the output should be similar to Fig 4.

 

Laravel Sail using Docker Desktop on Mac - Sail Up

Fig 3

 

It might throw the error - ERROR: Service 'laravel.test' failed to build : Build failed. In such a case, you might be required the same command several times. It worked in the third attempt on my system. We can also try rebuilding it using the command as shown below.

 

# Sail Up without ./
vendor/bin/sail up

 

Laravel Sail using Docker Desktop on Mac - Sail Up Completed

Fig 4

 

On the successful start of the application's Docker containers, we can access the application using the preferred web browser at: http://127.0.0.1. The default page should be similar to Fig 5.

 

Laravel Sail using Docker Desktop on Mac - Home Page

Fig 5

 

We can press Ctrl + C to exit and stop all the containers as shown in Fig 6.

 

Laravel Sail using Docker Desktop on Mac - Stop

Fig 6

 

Summary

 

This tutorial provided the links to useful resources and the steps required to install and launch your first Laravel Application using Laravel Sail and Docker Desktop on macOS Catalina.

share on :

Profile picture for user bhagwatchouhan
bhagwatchouhan