Skip to content

Commit d30cc12

Browse files
humitosagjohnson
authored andcommitted
Upgrade docker-py to its latest version (docker==3.1.1) (#3243)
* Upgrade docker-py to its latest version (1.10.6) * Hardcode 1.19 as Docker version * Upgrade to latest possible docker/requests version * Lint * Fix import mistake from previous merge * Fix merge conflict on creating container host config * Remove unused import * create_host_config fixed by calling it from the Docker client * Upgrade docker and requests to their latest versions
1 parent 50e7d4b commit d30cc12

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

readthedocs/doc_builder/environments.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
import socket
1515
from datetime import datetime
1616

17-
from readthedocs.core.utils import slugify
1817
from django.conf import settings
1918
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
2220
from docker.errors import APIError as DockerAPIError, DockerException
2321
from slumber.exceptions import HttpClientError
2422

2523
from readthedocs.builds.constants import BUILD_STATE_FINISHED
2624
from readthedocs.builds.models import BuildCommandResultMixin
25+
from readthedocs.core.utils import slugify
2726
from readthedocs.projects.constants import LOG_TEMPLATE
2827
from readthedocs.restapi.client import api as api_v2
2928
from requests.exceptions import ConnectionError
@@ -723,10 +722,9 @@ def get_client(self):
723722
"""Create Docker client connection."""
724723
try:
725724
if self.client is None:
726-
self.client = Client(
725+
self.client = APIClient(
727726
base_url=self.docker_socket,
728727
version=DOCKER_VERSION,
729-
timeout=None
730728
)
731729
return self.client
732730
except DockerException as e:
@@ -778,9 +776,12 @@ def get_container_host_config(self):
778776
self.project.pip_cache_path: {
779777
'bind': self.project.pip_cache_path,
780778
'mode': 'rw',
781-
}
779+
},
782780
})
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+
)
784785

785786
@property
786787
def container_id(self):
@@ -839,7 +840,6 @@ def create_container(self):
839840
host_config=self.get_container_host_config(),
840841
detach=True,
841842
environment=self.environment,
842-
mem_limit=self.container_mem_limit,
843843
)
844844
client.start(container=self.container_id)
845845
except ConnectionError as e:

readthedocs/rtd_tests/mocks/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self):
4444
'readthedocs.doc_builder.backends.sphinx.EpubBuilder.move'),
4545
'glob': mock.patch('readthedocs.doc_builder.backends.sphinx.glob'),
4646

47-
'docker': mock.patch('readthedocs.doc_builder.environments.Client'),
47+
'docker': mock.patch('readthedocs.doc_builder.environments.APIClient'),
4848
'docker_client': mock.Mock(),
4949
}
5050
self.mocks = {}

requirements/pip.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ stripe==1.20.2
6868

6969
django-formtools==2.1
7070
django-dynamic-fixture==2.0.0
71-
docker-py==1.3.1
71+
docker==3.1.1
7272
django-textclassifier==1.0
7373
django-annoying==0.10.4
7474
django-messages-extends==0.6.0

0 commit comments

Comments
 (0)