1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 03:45:28 +01:00
Files
atomic/Atomic/client.py
Brent Baude b09a1bc4d0 Atomic/client.py: Universal method for docker.Client()
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.
2016-02-16 10:41:19 -06:00

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())