Methods
-
Class construct
-
all() : arrayList all containers on the server.
-
List all containers on the server.
-
Get the current state of the container.
-
setState(string $name, string $action, int $timeout, bool $force, bool $stateful, bool $wait) : arrayMain set state method for a container, methods below are shortcuts.
-
Start a container.
-
Stop a container.
-
Shutdown a container - alias of stop.
-
Restart a container.
-
Reboot a container - alias of restart.
-
Freeze a container.
-
Pause a container - alias of freeze.
-
Unfreeze a container.
-
Thaw a container - alias of unfreeze.
-
Create a container from an image (local or remote).
-
Create a copy of an existing local container.
-
Replace the configuration of a container
-
Private method for getting container [source] options.
-
Private method for getting container [default] options.
-
Private method for getting default container [empty] options.
-
Private method for getting default container [remote] options.
-
Private method for getting default container [local] options.
Methods Details
-
public function __construct(array $config, variable $curl)Class construct
-
public function all()List all containers on the server.
$lxd->containers->all();
-
public function info(string $name)List all containers on the server.
$lxd->containers->info('container-name');
-
public function state(string $name)Get the current state of the container.
$lxd->containers->state('container-name');
-
public function setState(string $name, string $action, int $timeout, bool $force, bool $stateful, bool $wait)Main set state method for a container, methods below are shortcuts.
$lxd->containers->setState('container-name', 'start', 30, true, true, true);
-
public function start(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Start a container.
$lxd->containers->start('container-name', 30, true, true, true);
-
public function stop(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Stop a container.
$lxd->containers->stop('container-name', 30, true, true, true);
-
public function shutdown(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Shutdown a container - alias of stop.
$lxd->containers->shutdown('container-name', 30, true, true, true);
-
public function restart(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Restart a container.
$lxd->containers->restart('container-name', 30, true, true, true);
-
public function reboot(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Reboot a container - alias of restart.
$lxd->containers->reboot('container-name', 30, true, true, true);
-
public function freeze(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Freeze a container.
$lxd->containers->freeze('container-name', 30, true, true, true);
-
public function pause(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Pause a container - alias of freeze.
$lxd->containers->pause('container-name', 30, true, true, true);
-
public function unfreeze(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Unfreeze a container.
$lxd->containers->unfreeze('container-name', 30, true, true, true);
-
public function thaw(string $name, int $timeout, bool $force, bool $stateful, bool $wait)Thaw a container - alias of unfreeze.
$lxd->containers->thaw('container-name', 30, true, true, true);
-
public function create(string $name, array $options, bool $wait)Create a container from an image (local or remote).// Create container from image specified by alias $lxd->containers->create( "test", [ "alias" => "ubuntu/xenial/amd64", ] ); // Create container from image specified by fingerprint $lxd->containers->create( "test", [ "fingerprint" => "097e75d6f7419d3a5e204d8125582f2d7bdd4ee4c35bd324513321c645f0c415", ] ); // Create container based on most recent match of image properties $lxd->containers->create( "test", [ "properties" => [ "os" => "ubuntu", "release" => "14.04", "architecture" => "x86_64", ], ] ); // Create an empty container $lxd->containers->create( "test", [ "empty" => true, ] ); // Create container with custom configuration. // - Set the MAC address of the container's eth0 device $lxd->containers->create( "test", [ "alias" => "ubuntu/xenial/amd64", "config" => [ "volatile.eth0.hwaddr" => "aa:bb:cc:dd:ee:ff", ], ] ); // Create container and apply profiles to it $lxd->containers->create( "test", [ "alias" => "ubuntu/xenial/amd64", "profiles" => ["migratable", "unconfined"], ] ); // Create container from a publicly-accessible remote image $lxd->containers->create( "test", [ "server" => "https://images.linuxcontainers.org:8443", "alias" => "ubuntu/xenial/amd64", ] ); // Create container from a private remote image (authenticated by a secret) $lxd->containers->create( "test", [ "server" => "https://private.example.com:8443", "alias" => "ubuntu/xenial/amd64", "secret" => "my_secrect", ] );
-
public function copy(string $name, string $copyName, array $options, bool $wait)Create a copy of an existing local container.// Copy container $lxd->containers->copy('existing', 'new'); // Copy container and apply profiles to it $lxd->containers->copy( 'container-name', 'copy-container-name', 'profiles' => ['default', 'public'] );
-
public function replace(string $name, array $opts, bool $wait)Replace the configuration of a containerConfiguration is overwritten, not merged. Clients should first call the info method to obtain the current configuration of a container. The resulting objects metadata should be modified and then passed to the relace method. // Change container to be ephemeral $container = $lxd->containers->info('container-name'); $container['metadata']['ephemeral'] = true; $lxd->containers->replace('container-name', $$container['metadata']);
-
final private function getSource(array $options)Private method for getting container [source] options.
-
final private function getOptions(string $name, array $options)Private method for getting container [default] options.
-
final private function getEmptyOptions(string $name, array $options)Private method for getting default container [empty] options.
-
final private function getRemoteImageOptions(string $name, array $source, array $options)Private method for getting default container [remote] options.
-
final private function getLocalImageOptions(string $name, array $source, array $options)Private method for getting default container [local] options.