Image Variations

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
ProcessesOne: the command you pass. No supervisor.
PortsNone
Stop signalSIGTERM
Default health checkNone
Webroot variableNot used
PHP versions8.1 to 8.6
Operating systemsDebian 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:

Terminal
docker run --rm -it -v "$(pwd):/var/www/html" serversideup/php:8.5-cli bash

Or run one command and exit:

Terminal
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:

compose.yml
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:

Terminal
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.