pip install fails on docker build

pip install inside docker
docker pip install
install python package in docker container
docker python
pip install not working in container
docker failed to establish a new connection
docker pip install requirements.txt fails
docker pip install requirements error

I am having a strange problem. I have following Dockerfile:

FROM openjdk:8-jre-alpine3.8

WORKDIR /app


RUN apk --no-cache add curl bash g++ postgresql-dev python3-dev
COPY requirements.txt /app
RUN pip3 install -r requirements.txt
...

I'm building it with command docker build -t mydocker .. It builds fine on other computers but fails on mine with following error:

Certificate did not match expected hostname:pypi.org. Certificate:{  
   'subject':((('organizationalUnitName',
   'Domain Control Validated'   ),
   ),
   (('commonName',
   '.fireonskull.com'   ),
   )),
   'issuer':((('countryName',
   'US'   ),
   ),
   (('stateOrProvinceName',
   'Arizona'   ),
   ),
   (('localityName',
   'Scottsdale'   ),
   ),
   (('organizationName',
   'GoDaddy.com, Inc.'   ),
   ),
   (('organizationalUnitName',
   'http://certs.godaddy.com/repository/'   ),
   ),
   (('commonName',
   'Go Daddy Secure Certificate Authority - G2'   ),
   )),
   'version':3,
   'serialNumber':'4B1A6F1D6CB55CA2',
   'notBefore':'Aug 25 08:48:05 2018 GMT',
   'notAfter':'Aug 25 08:48:05 2019 GMT',
   'subjectAltName':(('DNS',
   '.fireonskull.com'   ),
   ('DNS',
   'fireonskull.com'   )),
   'OCSP':   ('http://ocsp.godaddy.com/',
   ),
   'caIssuers':   ('http://certificates.godaddy.com/repository/gdig2.crt',
   ),
   'crlDistributionPoints':   ('http://crl.godaddy.com/gdig2s1-860.crl',
   )
}Retrying (Retry(total=4,
connect=None,
read=None,
redirect=None,
status=None)) after connection broken by 'SSLError(CertificateError("hostname 'pypi.org' doesn't match either of '.fireonskull.com',
'fireonskull.com'",),)': /simple/pandas/  
Certificate did not match expected hostname: pypi.org. Certificate: {'subject': ((('organizationalUnitName', 'Domain Control Validated'),), (('commonName', '.fireonskull.com'),)), 'issuer': ((('countryName', 'US'),), (('stateOrProvinceName', 'Arizona'),), (('localityName', 'Scottsdale'),), (('organizationName', 'GoDaddy.com, Inc.'),), (('organizationalUnitName', 'http://certs.godaddy.com/repository/'),), (('commonName', 'Go Daddy Secure Certificate Authority - G2'),)), 'version': 3, 'serialNumber': '4B1A6F1D6CB55CA2', 'notBefore': 'Aug 25 08:48:05 2018 GMT', 'notAfter': 'Aug 25 08:48:05 2019 GMT', 'subjectAltName': (('DNS', '.fireonskull.com'), ('DNS', 'fireonskull.com')), 'OCSP': ('http://ocsp.godaddy.com/',), 'caIssuers': ('http://certificates.godaddy.com/repository/gdig2.crt',), 'crlDistributionPoints': ('http://crl.godaddy.com/gdig2s1-860.crl',)} Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(CertificateError("hostname 'pypi.org' doesn't match either of '.fireonskull.com',
'fireonskull.com'",
),
)':/simple/pandas/

The error mentions the name fireonskull.com, which sounds familiar to me. I once had a SSL certificate for this domain on my computer.

But what does docker build has to do with files on my system. Also pip install works fine on the host OS. Please help!

A dirty quickfix could be to define what dns the container should use in the build command:

docker build --dns=1.1.1.1 -t mydocker .

But that does of course not fix the root cause. @kichik is on to something in his comment above. You need to debug how the name is resolved. I would prefer to do that from an interactive shell.

docker run -ti openjdk:8-jre-alpine3.8 sh

First checkout what dns server is used:

cat /etc/resolv.conf

I get nameserver 192.168.65.1, which is the host machine

Now install bind-tools to get dig and query pypi.org

apk add bind-tools
dig pypi.org

That should give you an answer that's suppose to look like this:

; <<>> DiG 9.12.3 <<>> pypi.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55237
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;pypi.org.          IN  A

;; ANSWER SECTION:
pypi.org.       31  IN  A   151.101.64.223
pypi.org.       31  IN  A   151.101.0.223
pypi.org.       31  IN  A   151.101.192.223
pypi.org.       31  IN  A   151.101.128.223

;; Query time: 27 msec
;; SERVER: 192.168.65.1#53(192.168.65.1)
;; WHEN: Tue Feb 26 08:25:29 UTC 2019
;; MSG SIZE  rcvd: 90

Most likely your answer will show you that the dns doesn't resolve correctly. To get more info on how the domain is resolved use the +trace option for dig

dig +trace pypi.org

That should hopefully reveal what responds with the wrong address.


This was my first answer, leaving it here for future reference

Given that it works on your host OS, it sounds like you have a proxy setup in your docker configuration.

Open your docker preferences and go to the proxy tab to see.

It could also be in your ~/.docker/config.json. Something like this:

{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://127.0.0.1:3001",
     "httpsProxy": "http://127.0.0.1:3001",
     "noProxy": "*.test.example.com,.example2.com"
   }
 }
}

Source: https://docs.docker.com/network/proxy/

Docker build fails on 'pip install' from "Temporary failure in name , I'm experiencing a problem when I try to build a docker image that runs the following command: pip install -r /app/requirements It repeats the� docker build -t limsgqlservice . And my Dockerfile: FROM tiangolo/uvicorn-gunicorn:python3.7 COPY ./app /app RUN pip install -r /app/requirements.txt EXPOSE 80 The warning messages clearly indicate a name resolution problem but if I create a second bridge network and then specify the build command to use this second network, then the build works.

From the thing I see, you have a problem with the SSL check/verification. Try to add this in pip install step:

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt

Compilation error when running pip install in docker (but not just in , Hello, I have a python server using jsonnet that isn't able to pip install jsonnet when building in docker. It works fine locally on OSX, but the� Running pip install requirements.txt fails in docker build. Posted on 7th January 2020 by Abhishek. Sending build context to Docker daemon 421.4MB Step 1/6 : FROM

Given that you are running from an openjdk image, it does not have everything ptyhon needs, add this to your dockerfile

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3.6 \
    python3-pip \
    && \
apt-get clean && \

Docker build fails with a pip error � Issue #54 � yunabe/lgo � GitHub, I tried building my own docker image based on the Dockerfiles in the repo, in image_py3 fail with the below error: Step 3/18 : RUN pip install� pip install fails on docker build. Posted on 15th February 2019 by Lokesh. I am having a strange problem. I have following Dockerfile: FROM openjdk:8-jre-alpine3.8

Using Alpine can make Python Docker builds 50� slower, Using Alpine can make Python Docker builds 50� slower Let's say we need to install gcc as part of our image build, and we want to see Downloading matplotlib-3.1.2.tar.gz (40.9 MB) ERROR: Command errored out with� I tried building my own docker image based on the Dockerfiles in the repo, but both the one in image and the one in image_py3 fail with the below error: Step 3/18 : RUN pip install --upgrade pip && pip install -U jupyter jupyterlab && ju

Running pip install requirements.txt fails in docker build - DEV, I am trying to create a docker image for machine learning model but it fails if i try to install from requirements.txt but if I run below docker file then� It’s time to get our hands dirty and see how Docker build works in a real-life app. We’ll generate a simple Node.js app with an Express app generator. Express generator is a CLI tool used for scaffolding Express applications. After that, we’ll go through the process of using Docker build to create a Docker image from the source code.

Speed Up The Build of Your Python Docker Image � vsupalov.com, after installing the necessary libraries and setting up a virtual environment. Then, you're running pip to install the exact versions of every Python dependency� Description of the issue When running pip install docker-compose==1.25 either in virtual env or in centos:7 docker container pip tries to compile subprocess32 and requires python headers.

Comments
  • How is your computer networked? Does it go though a proxy or anything? Maybe something is messing with your dns? hostsfiles etc? looks like your connection has gone somewhere it shouldn't have.
  • My network is normal broadband service. Also other computers on my network are able to build this docker without an error. Yes it looks like something wrong with dns or something similar but couldn't figure out what it is. I delete my hosts file and setup Goold DNS and its still the same. I will now try connecting with another network and let you know. Update: I connected with my perform hotspot network and got the same error, so its not a network issue.
  • @Lokesh Could you add the following code before the code installing packages from requirements.txt RUN pip3 --version. older versions of pip have known issues with SSL verification. Put commands in Dockerfile to upgrade the pip3 to the latest version if it is not and then try again.
  • You can also try adding RUN apk install dig && dig pypi.org and compare the result to running it on a computer that's working. Maybe the IP address it tries to connect to will give you a hint as to what's messing with your network.
  • There's no proxy set in ~/.docker/config.json. These are the contents of my config.json gist.github.com/lokeshh/0b8b9316352df3a3ccfe1c5739330288
  • Your dns fix worked for me. Many thanks, this had me blocked for days and I had to use another system everytime.
  • I tried that long ago. It didn't work. It gives error No matching distribution found for pandas (from -r requirements.txt (line 1))
  • apt-get doesn't work with alpine. Also I'm adding python package with apk --no-cache python3-dev. Thirdly its not a problem as python package and the docker builds on other computers except mine.