Appearance
Containers
Needs the scope console-containers (console-containers:read for reading). The REST endpoints are described on Containers.
php
$containers = $console->containers();
foreach ($containers->list() as $container) { … } // without status
$container = $containers->find($id); // with status: running, stopped (null: unknown)Actions
Every action is available on the endpoint (with the id) and on a Container resource:
| On the resource | On the endpoint | Result |
|---|---|---|
$container->update(['name' => 'game-2']) | $containers->update($id, [...]) | the changed Container; hostname inside after the next restart |
$container->delete() | $containers->delete($id, $name) | confirmed with its name (the resource sends its own); kept 14 days |
$container->power('reboot') | $containers->power($id, 'reboot') | Accepted (202): start, stop, shutdown, reboot |
$container->reinstall($templateId, $sshKeyId, $options) | $containers->reinstall($id, $templateId, $sshKeyId, $options) | Accepted; all data and snapshots are lost |
$container->refresh() | $containers->find($id) | reads the container again |
reinstall() keeps the LXC options unless you pass new ones as third argument (null keeps them).
Backups and snapshots
php
$container->backups()->list(); // or $containers->backups($id)->list()
$container->backups()->create('before update');
$container->backups()->restore($backupId);
$container->backups()->delete($backupId);
$container->snapshots()->list();
$container->snapshots()->create('before_update', 'Before the update');
$container->snapshots()->rollback('before_update');
$container->snapshots()->delete('before_update');Operations answering 202 (power, reinstall, backups, snapshots) run in the background; read the container again, or wait for the product.updated webhook.
LXC options and GPUs
php
use Anikeen\Console\Resources\Container;
$container->options; // {features: ["fuse", "keyctl"], devices: ["tun"]}
$container->hasFeature(Container::FEATURE_FUSE);
$container->hasDevice(Container::DEVICE_TUN); // true
$container->gpu; // {vendor, model, vram_gb, mode, count} or null| Constant | Value |
|---|---|
Container::FEATURE_FUSE | fuse |
Container::FEATURE_KEYCTL | keyctl |
Container::DEVICE_TUN | tun |
Containers::POWER_ACTIONS | ['start', 'stop', 'shutdown', 'reboot'] |
Not covered yet
The SDK's reinstall() does not take a post-install script yet. Use the REST API for that - see Post-install scripts:
php
$console->call('POST', "containers/{$id}/reinstall", [
'template_id' => $templateId,
'post_install_script' => $script,
]);