PHPackages                             sharryy/docker-sandbox - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. sharryy/docker-sandbox

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

sharryy/docker-sandbox
======================

A simple, secure and fluent PHP API for running untrusted code in isolated Docker containers.

v0.1.0(today)00MITPHPPHP ^8.3CI passing

Since Jun 22Pushed todayCompare

[ Source](https://github.com/sharryy/docker-sandbox)[ Packagist](https://packagist.org/packages/sharryy/docker-sandbox)[ Docs](https://github.com/sharryy/docker-sandbox)[ GitHub Sponsors](https://github.com/sharryy)[ RSS](/packages/sharryy-docker-sandbox/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Docker Sandbox — run code safely in Docker containers
=====================================================

[](#docker-sandbox--run-code-safely-in-docker-containers)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6640324e4ab48ef45f5baa3c5b2b3165058c39cc19572a142edc0a18a55fe11a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736861727279792f646f636b65722d73616e64626f782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sharryy/docker-sandbox)[![Tests](https://camo.githubusercontent.com/b9186038f3656d3138f345b05d3f865b7f698bfb74686f0d810d93c651e32284/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736861727279792f646f636b65722d73616e64626f782f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sharryy/docker-sandbox/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/35776c1210ac7d7ce02eb7d1e2acd8c02fa4570323b169d2b4a6cd4f9b86719f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736861727279792f646f636b65722d73616e64626f782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sharryy/docker-sandbox)

A simple, secure and fluent PHP API for running untrusted code in isolated Docker containers. It talks directly to the Docker Engine API over a unix socket or TCP/TLS — no shelling out to the `docker` CLI — and makes the *easiest* way to run code also the *most locked-down* one.

Demo
----

[](#demo)

[![Code Arena — running code safely in a sandbox](.github/demo.gif)](.github/demo.gif)

The clip above is **[Code Arena](https://github.com/sharryy/code-arena)**, a playground built on this package: run PHP, Python or Node in a sandbox and watch it block a network call, refuse a write to its filesystem, and grade HackerRank-style challenges — all in throwaway containers.

Installation
------------

[](#installation)

```
composer require sharryy/docker-sandbox
```

Requires PHP 8.3+, the cURL extension, and access to a Docker daemon (Docker Desktop, Colima, Lima, or a remote daemon over TCP/TLS).

> **Note:** The package is developed and tested on Linux and macOS. Windows is not supported or tested — the test suite requires a Linux Docker daemon.

Quick start
-----------

[](#quick-start)

```
use Sharryy\Docker\Sandbox;

$sandbox = new Sandbox();

$result = $sandbox->php('
