Skip to content

Commit

Permalink
support docker-py-2.x
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
  • Loading branch information
TomasTomecek committed Feb 10, 2017
1 parent 66979ef commit 52fd952
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sen/docker_backend.py
Expand Up @@ -744,12 +744,20 @@ def __init__(self):
self._containers = None
self._images = None # displayed images
self._all_images = None # docker images -a
kwargs = docker.utils.kwargs_from_env(assert_hostname=False)
# kwargs["timeout"] = 1 # when debugging timeouts

kwargs = {"version": "auto"}
kwargs.update(docker.utils.kwargs_from_env(assert_hostname=False))

try:
self.client = docker.AutoVersionClient(**kwargs)
APIClientClass = docker.Client # 1.x
except AttributeError:
APIClientClass = docker.APIClient # 2.x

try:
self.client = APIClientClass(**kwargs)
except docker.errors.DockerException as ex:
raise TerminateApplication("can't establish connection to docker daemon: {0}".format(str(ex)))

self.scratch_image = RootImage(self)

# backend queries
Expand Down

0 comments on commit 52fd952

Please sign in to comment.