CLI
The cli variation runs PHP from the command line, with no web server and no process supervisor. Choose it for Composer, one-off scripts, running PHP without installing it on your machine, or Laravel Octane on Swoole or RoadRunner. Compare every variation →
At a glance
cli | |
|---|---|
| Processes | One: the command you pass. No supervisor. |
| Ports | None |
| Stop signal | SIGTERM |
| Default health check | None |
| Webroot variable | Not used |
| PHP versions | 8.1 to 8.6 |
| Operating systems | Debian and Alpine |
The image also includes composer and install-php-extensions. See default configurations for the full list of extensions and settings.
Quick start
Mount your project into /var/www/html and open a shell:
docker run --rm -it -v "$(pwd):/var/www/html" serversideup/php:8.5-cli bash
Or run one command and exit:
docker run --rm -v "$(pwd):/var/www/html" serversideup/php:8.5-cli composer install
Alpine images have no bash. Use sh with serversideup/php:8.5-cli-alpine.
With Docker Compose
Define the service once:
services:
php:
image: serversideup/php:8.5-cli
volumes:
- ./:/var/www/html
Then run commands through it. The first php is the service name and the second is the command:
docker compose run --rm php php my-script.php
Laravel workers and the scheduler
Queue workers, Horizon, and the scheduler usually run from the same image as your web app with a different command, so every container has the same code and extensions. See Laravel workers for the commands and health checks.
Related pages
- Environment variable specification: every
PHP_*setting - Command reference: helper commands inside the container
- Installing additional PHP extensions