Skip to content

Use Docker image

parallel-processses provide Docker images with everything installed: PHP, the library and Docker.

You can choose between this 3 versions:

  • alpine: smallest version, but could be "too much simple" sometimes
  • buster: middle version, contains almost everything needed
  • bookworm: larger version, should contain what you need

Dependencies

  • OS: Linux, Windows and macOS
  • Docker: you should already have a compatible version

Basic usage

See minimal configuration to create your parallel processes configuration.

Then you can use official images to execute it:

docker \
    run \
        --rm \
        -it \
        -v "$(pwd)":/app \
        steevanb/php-parallel-processes:1.1.0-alpine \
            php /app/parallel-processes.php

Docker outside of Docker (DooD)

If your processes need to execute Docker commands on your host, you can do it with DooD.

You have to add a volume to your Docker socket, that's all:

docker \
    run \
        --rm \
        -it \
        -v "$(pwd)":/app \
        -v /var/run/docker.sock:/var/run/docker.sock \
        steevanb/php-parallel-processes:1.1.0-alpine \
            php /app/parallel-processes.php 

docker.sock host path

Use docker context inspect to get your socket path if it's not /var/run/docker.sock.

In this case, keep /var/run/docker.sock for the volume target.

Examples of processes that use the Docker host's socket:

<?php

use Steevanb\ParallelProcess\{
    Console\Application\ParallelProcessesApplication,
    Process\Process
};
use Symfony\Component\Console\Input\ArgvInput;

require $_ENV['COMPOSER_GLOBAL_AUTOLOAD_FILE_NAME'];

(new ParallelProcessesApplication())

    // This command will be executed in the parallel-processes Docker container,
    // but it will use the host's Docker socket
    // It’s almost as if it were executed directly on the host
    ->addProcess(new Process(['docker', 'build']))

    // You can use Docker compose plugin
    ->addProcess(new Process(['docker', 'compose', 'build']))

    // You can use Docker buildx plugin, but only with buster and bookworm images
    // alpine do not contain buildx
    ->addProcess(new Process(['docker', 'buildx', 'build']))

    ->run(new ArgvInput($argv));

Official images are bundled with Docker and some plugins:

Image docker compose plugin buildx plugin
1.1.0-alpine
1.1.0-buster
1.1.0-bookworm

Docker is installed since 1.1.0

Docker, compose and buildx plugins are installed in Docker images since 1.1.0.

Available versions

See Docker tags.

See changelog.