How to check running container in Laravel 8?

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.

CommandDescription
./vendor/bin/sail upRun Laravel 8 app inside containers
./vendor/bin/sail downDestroy your application and all running containers
./vendor/bin/sail up -dRun containers in background or in deamon mode
./vendor/bin/sail artisanRun Laravel artisan commands using sail without login to container
./vendor/bin/sail php -vCheck php version running inside your container
./vendor/bin/sail npm -vCheck npm version running inside your container
./vendor/bin/sail shareShare your site publicly in order to preview your site for a colleague