Skip to content

[CHORE] Prune Images from docker servers that havent been used for a given time #1586

@proditis

Description

@proditis

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions