createClient($socketClient, [ new ContentLengthPlugin(), new DecoderPlugin(), new AddHostPlugin(new Uri($host)), ], [ 'client_name' => 'docker-client', ]); } public static function createFromEnv(PluginClientFactory $pluginClientFactory = null): HttpClient { $options = [ 'remote_socket' => \getenv('DOCKER_HOST') ? \getenv('DOCKER_HOST') : 'unix:///var/run/docker.sock', ]; if (\getenv('DOCKER_TLS_VERIFY') && '1' === \getenv('DOCKER_TLS_VERIFY')) { if (!\getenv('DOCKER_CERT_PATH')) { throw new \RuntimeException('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable'); } $cafile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'ca.pem'; $certfile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'cert.pem'; $keyfile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'key.pem'; $stream_context = [ 'cafile' => $cafile, 'local_cert' => $certfile, 'local_pk' => $keyfile, ]; if (\getenv('DOCKER_PEER_NAME')) { $stream_context['peer_name'] = \getenv('DOCKER_PEER_NAME'); } $options['ssl'] = true; $options['stream_context_options'] = [ 'ssl' => $stream_context, ]; } return self::create($options, $pluginClientFactory); } }