diff --git a/readthedocs/doc_builder/environments.py b/readthedocs/doc_builder/environments.py index 504a74ac8f3..16d54967006 100644 --- a/readthedocs/doc_builder/environments.py +++ b/readthedocs/doc_builder/environments.py @@ -14,16 +14,15 @@ import socket from datetime import datetime -from readthedocs.core.utils import slugify from django.conf import settings from django.utils.translation import ugettext_lazy as _ -from docker import Client -from docker.utils import create_host_config +from docker import APIClient from docker.errors import APIError as DockerAPIError, DockerException from slumber.exceptions import HttpClientError from readthedocs.builds.constants import BUILD_STATE_FINISHED from readthedocs.builds.models import BuildCommandResultMixin +from readthedocs.core.utils import slugify from readthedocs.projects.constants import LOG_TEMPLATE from readthedocs.restapi.client import api as api_v2 from requests.exceptions import ConnectionError @@ -723,10 +722,9 @@ def get_client(self): """Create Docker client connection.""" try: if self.client is None: - self.client = Client( + self.client = APIClient( base_url=self.docker_socket, version=DOCKER_VERSION, - timeout=None ) return self.client except DockerException as e: @@ -778,9 +776,12 @@ def get_container_host_config(self): self.project.pip_cache_path: { 'bind': self.project.pip_cache_path, 'mode': 'rw', - } + }, }) - return create_host_config(binds=binds) + return self.get_client().create_host_config( + binds=binds, + mem_limit=self.container_mem_limit, + ) @property def container_id(self): @@ -839,7 +840,6 @@ def create_container(self): host_config=self.get_container_host_config(), detach=True, environment=self.environment, - mem_limit=self.container_mem_limit, ) client.start(container=self.container_id) except ConnectionError as e: diff --git a/readthedocs/rtd_tests/mocks/environment.py b/readthedocs/rtd_tests/mocks/environment.py index 0b7852c4a86..524db5419ec 100644 --- a/readthedocs/rtd_tests/mocks/environment.py +++ b/readthedocs/rtd_tests/mocks/environment.py @@ -44,7 +44,7 @@ def __init__(self): 'readthedocs.doc_builder.backends.sphinx.EpubBuilder.move'), 'glob': mock.patch('readthedocs.doc_builder.backends.sphinx.glob'), - 'docker': mock.patch('readthedocs.doc_builder.environments.Client'), + 'docker': mock.patch('readthedocs.doc_builder.environments.APIClient'), 'docker_client': mock.Mock(), } self.mocks = {} diff --git a/requirements/pip.txt b/requirements/pip.txt index 0fb48317964..f112870ef93 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -68,7 +68,7 @@ stripe==1.20.2 django-formtools==2.1 django-dynamic-fixture==2.0.0 -docker-py==1.3.1 +docker==3.1.1 django-textclassifier==1.0 django-annoying==0.10.4 django-messages-extends==0.6.0