MCPcopy Index your code
hub / github.com/google/clusterfuzz / check_docker_setup

Function check_docker_setup

cli/casp/src/casp/utils/docker_utils.py:68–93  ·  view source on GitHub ↗

Checks if Docker is installed, running, and has correct permissions. Returns: A docker.client object if setup is correct, None otherwise.

()

Source from the content-addressed store, hash-verified

66
67
68def check_docker_setup() -> docker.client.DockerClient | None:
69 """Checks if Docker is installed, running, and has correct permissions.
70
71 Returns:
72 A docker.client object if setup is correct, None otherwise.
73 """
74 try:
75 client = docker.from_env()
76 client.ping()
77 return client
78 except docker.errors.DockerException as e:
79 if 'Permission denied' in str(e):
80 click.secho(
81 'Error: Permission denied while connecting to the Docker daemon.',
82 fg='red')
83 click.echo('Please add your user to the "docker" group by running:')
84 click.secho(
85 f' sudo usermod -aG docker ${os.environ.get("USER")}', fg='yellow')
86 click.echo('Then, log out and log back in for the change to take effect.')
87 else:
88 click.secho(
89 'Error: Docker is not running or is not installed. Please start '
90 'Docker and try again.'
91 'Exception: {e}',
92 fg='red')
93 return None
94
95
96def pull_image(image: str) -> bool:

Callers 2

pull_imageFunction · 0.85
run_commandFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected