mirror of
https://github.com/projectatomic/atomic.git
synced 2026-02-06 03:45:28 +01:00
All uses of docker.Client() (docker-py) now should be using the DockerClient definition in client.py. Any changes to the client instantiation or function can now be changed in a singular location. Also, the DockerClient function has a fallback from docker.AutoVersionClient to docker.Client using a try and except condition. This fixes an issue raised in: https://github.com/projectatomic/atomic/issues/302 where atomic cannot be built due to imports when dockerd is not running.
13 lines
304 B
Python
13 lines
304 B
Python
import docker
|
|
from docker.utils import kwargs_from_env
|
|
|
|
def get_docker_client():
|
|
"""
|
|
Universal method to use docker.client()
|
|
"""
|
|
try:
|
|
return docker.AutoVersionClient(**kwargs_from_env())
|
|
|
|
except docker.errors.DockerException:
|
|
return docker.Client(**kwargs_from_env())
|