When a Laravel project runs on the docker environment. For example, after installing Laravel on Mac or Linux Operating System, you should know how to interact with docket containers. The First command we will learn to check running container will be the docker ps command.
You may open your terminal and type one of the following command to view all running containers:
# check all running containers
docker ps
# check all running container but in pretty format
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"
The above command shows you the following output.
How to check container logs in laravel 8?
To check the app container log you can run following command as shown below.
# first list all running container
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"
# pick the container ID or Name you want to check logs for
# then using container id or name check the container logs using following command
docker logs -f <containerID or containerName>
Useful Sail commands to interact with Laravel 8 app running in container
We now know that Laravel 8 uses sail commands to interact with your Laravel app running inside your container. You would need to know of some useful sail command in order to work with your Laravel 8 project.
Below is a list of some of the important commands you can use in your Laravel Sail CLI.
Command | Description |
---|---|
./vendor/bin/sail up | Run Laravel 8 app inside containers |
./vendor/bin/sail down | Destroy your application and all running containers |
./vendor/bin/sail up -d | Run containers in background or in deamon mode |
./vendor/bin/sail artisan | Run Laravel artisan commands using sail without login to container |
./vendor/bin/sail php -v | Check php version running inside your container |
./vendor/bin/sail npm -v | Check npm version running inside your container |
./vendor/bin/sail share | Share your site publicly in order to preview your site for a colleague |