Merge pull request #54 from jina-ai/fix-is-docker-running

fix: is docker running
This commit is contained in:
Florian Hönicke
2023-04-24 11:06:28 +02:00
committed by GitHub
2 changed files with 10 additions and 16 deletions

View File

@@ -185,7 +185,7 @@ def run_locally(executor_name, microservice_version_path):
use_docker = True
else:
click.echo('''
Docker daemon doesn\'t seem to be running.
Docker daemon doesn\'t seem to be running (possible reasons: incorrect docker installation, docker command isn\'t in system path, insufficient permissions, docker is running but unrespnsive).
It might be important to run your microservice within a docker container.
Your machine might not have all the dependencies installed.
You have 3 options:

View File

@@ -1,13 +1,9 @@
import os
import concurrent.futures
from typing import Generator
import subprocess
import sys
from contextlib import contextmanager
import docker
from docker import APIClient
def get_microservice_path(path, microservice_name, packages, num_approach, version):
package_path = '_'.join(packages)
@@ -44,14 +40,12 @@ def suppress_stdout():
def is_docker_running():
try:
from hubble import __windows__
_client = docker.from_env()
# low-level client
_raw_client = APIClient(
base_url=docker.constants.DEFAULT_NPIPE
if __windows__
else docker.constants.DEFAULT_UNIX_SOCKET
)
except Exception:
if sys.platform.startswith('win'):
command = 'docker info'
else:
command = 'docker info 2> /dev/null'
subprocess.check_output(command, shell=True)
return True
except subprocess.CalledProcessError:
return False
return True