There seems to be a network issue between CircleCI and PyPI when building Python-based Docker containers with pip. I am using the latest python:3.6 image. I can successfully build my image locally. The same commit hash that is failing now was working last week, so it seems likely that the issues lies in a change to the Docker daemon configuration by CircleCI. Below is an example of the error messages we are seeing in the build log.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f609f226f28>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/4a/c9/9d55c619475f27af12de1ac2d8d7326cbce0d3ea305bf07eb4e2930bf179/ddtrace-0.11.0.tar.gz