Allow pruning of images that havent been used in X amount of time to reduce the needs for storage from a docker container.
use Docker\Docker;
$docker = Docker::create([
'remote_socket' => 'tcp://REMOTE_HOST:2375' // or unix:///var/run/docker.sock
]);
// Filters for images: delete if not used in last 24h
$filters = [
'until' => ['24h']
];
// 'all' => true ensures all images are considered, not just dangling
$result = $docker->imagePrune([
'all' => true,
'filters' => json_encode($filters)
]);
print_r($result);