/** * Search the Docker image registry. */ public function testSearchImageRegistry() { $remote = new DockerRemoteRequest(); // Search the registry $this->assertNotEmpty($remote->Get(['uri' => '/images/search?term=ubuntu', 'accept' => 'application/json'])); }
/** * Retrieve info about the Docker daemon */ public function testInfo() { $remote = new DockerRemoteRequest(); // Retrieve docker daemon info $this->assertNotEmpty($remote->Get(['uri' => '/info', 'accept' => 'application/json'])); }
/** * Execute a command in a container. */ public function testExecuteCommand() { $remote = new DockerRemoteRequest(); // Create a new container. $container = $remote->Post(['uri' => '/containers/create?name=exec_container_test', 'content_type' => 'application/json', 'accept' => 'application/json', 'content' => ['Image' => 'ubuntu:15.10', 'Cmd' => ['/bin/bash']]]); // Start the container. $remote->Post(['uri' => '/containers/exec_container_test/start']); // Check the container is running. $inspect = $remote->Get(['uri' => '/containers/exec_container_test/json', 'accept' => 'application/json']); $this->assertTrue($inspect->State->Running); // Set up a exec instance on the container. $exec_id = $remote->Post(['uri' => '/containers/exec_container_test/exec', 'content_type' => 'application/json', 'accept' => 'application/json', 'content' => ['AttachStdin' => FALSE, 'AttachStdout' => TRUE, 'AttachStdErr' => TRUE, 'Tty' => FALSE, 'Cmd' => ['bash', '-c', 'echo "test"']]]); $this->assertNotEmpty($exec_id->Id); // Check the container is running. $inspect = $remote->Get(['uri' => '/containers/exec_container_test/json', 'accept' => 'application/json']); $this->assertTrue($inspect->State->Running); // Exec the exec instance. $result = $remote->Post(['uri' => '/exec/' . $exec_id->Id . '/start', 'content_type' => 'application/json', 'accept' => 'application/json', 'content' => ['Detach' => FALSE, 'Tty' => FALSE]]); }