|
14 | 14 | import socket
|
15 | 15 | from datetime import datetime
|
16 | 16 |
|
17 |
| -from readthedocs.core.utils import slugify |
18 | 17 | from django.conf import settings
|
19 | 18 | from django.utils.translation import ugettext_lazy as _
|
20 |
| -from docker import Client |
21 |
| -from docker.utils import create_host_config |
| 19 | +from docker import APIClient |
22 | 20 | from docker.errors import APIError as DockerAPIError, DockerException
|
23 | 21 | from slumber.exceptions import HttpClientError
|
24 | 22 |
|
25 | 23 | from readthedocs.builds.constants import BUILD_STATE_FINISHED
|
26 | 24 | from readthedocs.builds.models import BuildCommandResultMixin
|
| 25 | +from readthedocs.core.utils import slugify |
27 | 26 | from readthedocs.projects.constants import LOG_TEMPLATE
|
28 | 27 | from readthedocs.restapi.client import api as api_v2
|
29 | 28 | from requests.exceptions import ConnectionError
|
@@ -723,10 +722,9 @@ def get_client(self):
|
723 | 722 | """Create Docker client connection."""
|
724 | 723 | try:
|
725 | 724 | if self.client is None:
|
726 |
| - self.client = Client( |
| 725 | + self.client = APIClient( |
727 | 726 | base_url=self.docker_socket,
|
728 | 727 | version=DOCKER_VERSION,
|
729 |
| - timeout=None |
730 | 728 | )
|
731 | 729 | return self.client
|
732 | 730 | except DockerException as e:
|
@@ -778,9 +776,12 @@ def get_container_host_config(self):
|
778 | 776 | self.project.pip_cache_path: {
|
779 | 777 | 'bind': self.project.pip_cache_path,
|
780 | 778 | 'mode': 'rw',
|
781 |
| - } |
| 779 | + }, |
782 | 780 | })
|
783 |
| - return create_host_config(binds=binds) |
| 781 | + return self.get_client().create_host_config( |
| 782 | + binds=binds, |
| 783 | + mem_limit=self.container_mem_limit, |
| 784 | + ) |
784 | 785 |
|
785 | 786 | @property
|
786 | 787 | def container_id(self):
|
@@ -839,7 +840,6 @@ def create_container(self):
|
839 | 840 | host_config=self.get_container_host_config(),
|
840 | 841 | detach=True,
|
841 | 842 | environment=self.environment,
|
842 |
| - mem_limit=self.container_mem_limit, |
843 | 843 | )
|
844 | 844 | client.start(container=self.container_id)
|
845 | 845 | except ConnectionError as e:
|
|
0 commit comments