public function ensure() { writeln('Ensure docker-machine ' . $this->name); if (!$this->exists()) { $this->run(); } $command = "docker-machine status {$this->name}"; $output = Helpers::doLocal($command); if (!preg_match('#Running#i', $output, $matches)) { $this->start(); } $this->ip = Helpers::getMachineIp(); }
public function kill() { if ($this->exists()) { writeln('<comment>Kill web container</comment>'); $command = "docker rm -f {$this->container}"; Helpers::doLocal($command); } $command = "cd {$this->dir} && docker images"; $output = Helpers::doLocal($command); if (preg_match('/' . $this->image . '\\s.*latest\\s*([[:alnum:]]+).*/i', $output, $matches)) { $command = "cd {$this->dir} && docker rmi {$this->image}"; Helpers::doLocal($command); } }
public static function cleanup() { $web_name = basename(self::getProjectDir()); $web_name .= '_web'; $web = new Web($web_name); $web->stop(); $web->kill(); $image_id = null; $command = "docker images"; $output = Helpers::doLocal($command); $container = env('container'); $pattern = '#' . $container . '\\s.*latest\\s+(.*?)\\s#i'; if (preg_match($pattern, $output, $matches)) { $image_id = $matches[1]; } if ($image_id) { Helpers::doLocal('docker rmi -f ' . $image_id); } }
public function stop() { writeln("<comment>Stop running elasticsearch {$this->container}</comment>"); $command = "docker stop {$this->container}"; Helpers::doLocal($command); }
public function kill() { if ($this->exists()) { writeln("<comment>Kill Mysql container {$this->container}</comment>"); $command = "docker rm -f {$this->container}"; Helpers::doLocal($command); } }