docker build network error when trying to pip install - django

I am building my first docker install as part of learning django. I have my docker install working. docker info is ok. and hello-world says successfull. But when I run the Dockerfile suggested by the turorial in my Django 3.0 Pro Book by Will Vincent. I get what look like a network dns error.
################
Error:
Step 6/7 : RUN pip install pipenv && pipenv install --system
---> Running in 585e5020f53a
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f339144df10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3391f05a90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3391f05e90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3391f05ad0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f33915ddd90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
ERROR: Could not find a version that satisfies the requirement pipenv (from versions: none)
ERROR: No matching distribution found for pipenv
The command '/bin/sh -c pip install pipenv && pipenv install --system' returned a non-zero code: 1
####################
Dockerfile try to build:
Pull base image
FROM python:3.7
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory
WORKDIR /code
# Install dependencies
COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system
# Copy project
COPY . /code/
It is failing on the RUN pip install.... line.
I have added dns nameserver entries directly into my /etc/resolver.conf file as other have suggested in my search here. not worked.
I assume there is some issue within Docker trying to run pip in the container? This is my first Docker install so exhausted search for answer.
On OS version Centos8
Thanks
bill sanderson

Ok, we can try a couple of things. First thing I would do:
In the Dockerfile add this(with google's dns):
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf && pip install pipenv && pipenv install --system
It is important to do in the same RUN command.
Another option is:
docker build --network=host -t yourimage:yourversion .

I had the same issue last night - and this morning. Even after rebooting and trying to stop/start the service. This is on my Windows 10.
I did notice running a docker info output the following error:
Error response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file specified
As detailed here - https://stackoverflow.com/a/74098179/405022
Having ran wsl --shutdown and being prompted to restart docker desktop, I then proceeded to try my docker build.
docker build -f ./sources/service1/deploy/dev.dockerfile ./sources/service1 -t acme-app.service1-py:latest --no-cache --progress=plain
Coincidence? It worked for me in the end.

Related

Failed build in gitlab CI/CD at requirements.txt

The gitlab build fails with the following error:
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/asgiref/
ERROR: Could not find a version that satisfies the requirement asgiref (from versions: none)
ERROR: No matching distribution found for asgiref
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Cleaning up file based variables
ERROR: Job failed: command terminated with exit code 1
My Dockerfile is the following:
FROM registry.ubitech.eu/public-group/ubitech-public-registry/python:3.8
COPY manage.py gunicorn-cfg.py requirements.txt ./
COPY core core
COPY routers routers
COPY data_utilities data_utilities
COPY datasets datasets
COPY monitoring monitoring
RUN pip install -r requirements.txt
COPY cron_3.0pl1-137_amd64.deb ./
RUN dpkg -i cron_3.0pl1-137_amd64.deb
RUN mkdir logs
RUN touch logs/onenet_dashboard.log
EXPOSE 5005
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]
It is the first time that the build fails. Any idea of what is going wrong here?

Docker connection error 'Connection broken by NewConnectionError'

I am new to docker i just installed it and did some configuration for my django project.
when i am running docker build . i am getting these error whats wrong here?
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1363b604f0>: Failed to establish a new connection: [Errno -3] Try again')': /simple/django/
Dockerfile
FROM python:3.8-alpine
MAINTAINER RAHUL VERMA
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN mkdir /app
WORKDIR app
COPY ./app /app
RUN adduser -D user
USER user
requirements.txt file
Django==2.2
djangorestframework==3.11.0
I just do small changes to use your dockerfile and run command docker build -t app dockerfilelocation.
Its working from my side.My dockerfile look like -
FROM python:3.8-alpine
MAINTAINER RAHUL VERMA
ENV PYTHONUNBUFFERED 1
COPY . /app/
RUN pip install -r /app/requirements.txt
RUN mkdir /app
WORKDIR app
COPY ./app /app
RUN adduser -D user
USER user
I had the same problem it I solveit with the conections of internet or you can check it with this:
"This is almost certainly an issue with the networking/DNS configuration inside the container and not related to pip specifically. Try adding a RUN nslookup pypi.org line to your Dockerfile and see if it works. If you're using a custom index URL then put that instead of pypi.org."
https://github.com/pypa/pip/issues/7460

I got error while installing Django on pycharm

I am getting the following error while trying to install Django for python3
(base) C:\ShashiPractice ProjectStudent>pip install django
Collecting django
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED]
...
...
...
y failed: self signed certificate in certificate chain (_ssl.c:1056)')))
You made a small mistake.
The pip command is as follows:
pip install Django
Note that the the D in Django is in block letter. Hope this solves your problem :)

Error whenn installing awsebcli via Gitlab CLI

I have springboot project in gitlab that I try to deploy to Amazon Elastic Beanstalk environment that I created via Amazon web console.
In gitlab I am using Default shared Runners.
to deploy to AWS I must use 'eb' cli, for this I also need python
I tired to use this in my .gitlab-ci.yml
deploy:
stage: deploy
image: python:3.7.2-alpine3.7
script:
- pip install -r awsebcli
- eb use myenv-env -v
- eb deploy myenv-env -v
But got errors:
Pulling docker image python:3.7.2-alpine3.7 ...
Using docker image sha256:00be2573e9f79754b17954ba7a310a5f70c25b6f5bb78375e27e9e86d874877e for python:3.7.2-alpine3.7 ...
Running on runner-0c303413-project-4590-concurrent-0 via ed06f0845ef4...
Fetching changes...
Removing .m2/
Removing target/
HEAD is now at 5c19020 aws1
Checking out 5c190200 as master...
Skipping Git submodules setup
Checking cache for default...
Successfully extracted cache
Downloading artifacts for build (14719)...
Downloading artifacts from coordinator... ok id=14719 responseStatus=200 OK token=Yy7j2TGy
$ pip install -r awsebcli
Could not open requirements file: [Errno 2] No such file or directory: 'awsebcli'
ERROR: Job failed: exit code 1
Update
when I changed the line into:
pip3 install awsebcli
got:
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe6611ff2e8>: Failed to establish a new connection: [Errno -2] Name does not resolve')': /simple/awsebcli/
Could not find a version that satisfies the requirement awsebcli (from versions: )
No matching distribution found for awsebcli
The problem was proxy.
I added this:
pip3 --proxy=myProxy:myPort install awsebcli --upgrade

How to install Graphlab Create on Ubuntu?

When i am trying to install Graphlab Create, it's just retrying connections. I have healthy broadband wifi connection at my home (NO proxy).
Error: (graphlab)ankit#ankit21:~$ pip install graphlab-create==0.9.1
Collecting graphlab-create==0.9.1
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd6a16ae850>, 'Connection to 192.168.16.253 timed out. (connect timeout=15)')': /simple/graphlab-create/
The proxy 192.168.16.253 is proxy of my college internet. But i have changed the setting in networks setting to automatic proxy. Others installs in terminal are working properly only this is having the problem.
You need your specific academic license key, but trying to install the older version automatically updates your install to 1.7.1. If you choose to copy your code from the installation instructions and you remove --upgrade, and change to 0.9.1 it will still not work.
pip install --no-cache-dir https://get.dato.com/GraphLab-Create/0.9.1/your_key/GraphLab-Create-License.tar.gz
You can obtain your key for the latest version when you register with GraphLab on the Dato website. The academic license is free for each user for one year.
On the official site (https://turi.com/download/install-graphlab-create.html?email=**YOU**%40gmail.com&key=**7C68-...-D3D7**) we have:
Registered email address: YOUR_ADDRESS
Product key: YOUR_PRODUCT_KEY
Installing with dependencies:
Install Anaconda
bash /path to download file/Anaconda2-4.0.0-Linux-x86_64.sh
Create conda environment
conda create -n gl-env python=2.7 anaconda=4.0.0
source activate gl-env
Ensure pip version >= 7
conda update pip
Install GraphLab Create
pip install --upgrade --no-cache-dir https://get.graphlab.com/GraphLab-Create/2.1/YOUR_ADDRESS/YOUR_PRODUCT_KEY/GraphLab-Create-License.tar.gz
Ensure installation of IPython and IPython Notebook
conda install ipython-notebook