Pip cannot install packages while building docker container - docker

Im building an docker container in remote host with CentOS in it. When its time for PIP to install packages from requirements.txt i get following warning and error.
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 0x7f989f889978>: Failed to establish a new connection: [Errno -3] Try again',)': /simple/pip/
and after all retries i get this error
ERROR: Could not find a version that satisfies the requirement connexion[swagger-ui] (from -r /tmp/requirements.txt (line 1)) (from versions: none) ERROR: No matching distribution found for connexion[swagger-ui] (from -r /tmp/requirements.txt (line 1)) ERROR: Service 'api' failed to build: The command '/bin/sh -c pip install -U pip && pip install -r /tmp/requirements.txt' returned a non-zero code: 1 make: *** [compose-build-nocache] Error 1
Things i have tried.
I used docker build commnd with --network=host flag and it executes fine.
and after this build if i use ping inside container to any site it failes.
i build image locally and then load in remote host it works but i cannot curl to localhost where the application throws output.

Related

Gitlab CI error : Could not build wheels for glpk which use PEP 517 and cannot be installed directly

I have installed in my windows machine locally glpk successfully and runs. However, as a part of Gitlab CI, when I push into Gitlab I am getting the following error:
Building wheel for glpk (PEP 517): started
Building wheel for glpk (PEP 517): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpr4_114h3
cwd: /tmp/pip-install-dj24wr4l/glpk_fa702cebdf2c4db9a16294c1def2434d
Complete output (16 lines):
running bdist_wheel
running build
running build_ext
building 'glpk' extension
creating build
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DVERSION_NUMBER=\"0.4.6\" -I/usr/local/include/python3.8 -c src/2to3.c -o build/temp.linux-x86_64-cpython-38/src/2to3.o
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DVERSION_NUMBER=\"0.4.6\" -I/usr/local/include/python3.8 -c src/bar.c -o build/temp.linux-x86_64-cpython-38/src/bar.o
In file included from src/bar.h:24,
from src/bar.c:22:
src/lp.h:24:10: fatal error: glpk.h: No such file or directory
24 | #include <glpk.h>
| ^~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for glpk
Building wheel for pymeeus (setup.py): started
Building wheel for pymeeus (setup.py): finished with status 'done'
Created wheel for pymeeus: filename=PyMeeus-0.5.11-py3-none-any.whl size=730985 sha256=1cab3ff9087153d2f105c80f95e88cf44ecf87a7489bef56745c268dfe038b8c
Stored in directory: /root/.cache/pip/wheels/a0/8b/b2/810ae5a6f970c8be4725353400d643c90de1c0f023a9884ee7
Successfully built unipath django-crontab pymeeus
Failed to build glpk
ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 21.2.4; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Cleaning up file based variables
00:00
ERROR: Job failed: command terminated with exit code 1
I have to note that I do not remember what I did to make glpk run locally and I just added glpk in my requirements.txt file, but this apparently is not correct. What should I do to bypass this error in Gitlab CI? Do I have to add anything in my Dockerfile?
EDIT1: My Dockerfile is the following:
FROM registry.ubitech.eu/public-group/ubitech-public-registry/python:3.6
COPY manage.py gunicorn-cfg.py requirements.txt ./
COPY authentication authentication
COPY core core
COPY routers routers
COPY clustering clustering
COPY data_utilities data_utilities
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/phoenix_dashboard.log
EXPOSE 5005
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]
EDIT2: When I am trying the solution provided here I am getting the following error:
Step 8/15 : RUN apt install libglpk-dev python3.8-dev libgmp3-dev
---> Running in 0b141af248f9
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Package libgmp3-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libgmp-dev
E: Unable to locate package libglpk-dev
E: Unable to locate package python3.8-dev
E: Couldn't find any package by glob 'python3.8-dev'
E: Package 'libgmp3-dev' has no installation candidate
The command '/bin/sh -c apt install libglpk-dev python3.8-dev libgmp3-dev' returned a non-zero code: 100
Cleaning up file based variables
00:00
ERROR: Job failed: command terminated with exit code 1
fatal error: glpk.h: No such file or directory
You are missing the header file(s) for glpk. To make sure this is available, install the library:
RUN apt update && apt install -y libglpk-dev

jenkins gnutls_handshake() failed: Handshake failed

I'm trying to install jenkins on Ubuntu14.04 following this site.
After executing the last step, the terminal shows this error:
Err https://pkg.jenkins.io/debian-stable/ binary/ jenkins 2.235.5
gnutls_handshake() failed: Handshake failed
E: Failed to fetch https://pkg.jenkins.io/debian-stable/binary/jenkins_2.235.5_all.deb gnutls_handshake() failed: Handshake failed
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
I tried to run sudo apt-get update --fix-missing (no errow shown after running this cmd) but it doesn't help.
I also tried to install by downloading jenkins.war but the jenkins service isn't enabled after installing.
Please show me how to fix this issue.
The issue seems to be upstream (I have hit the same snag this morning trying to update one of my jenkins installls).
You could use wget and dpkg to fetch and install the deb package:
wget https://pkg.jenkins.io/debian-stable/binary/jenkins_2.235.5_all.deb && sudo dpkg -i jenkins_2.235.5_all.deb
Which will get you Jenkins installed.

Error /dev/tty: No such device or address when installing sqlcmd inside docker

I wanted to install sql cmd in my docker image.
My dockerfile has these commands to install sqlcmd (centos 7 base image)
RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
RUN yum remove mssql-tools unixODBC-utf16-devel
RUN yum install -y unixODBC-devel mssql-tools
Below is the docker build logs
Transaction test succeeded
Running transaction
Updating : libcom_err-1.42.9-17.el7.x86_64 1/14
Installing : unixODBC-2.3.7-1.rh.x86_64 2/14
Updating : libss-1.42.9-17.el7.x86_64 3/14
Installing : e2fsprogs-libs-1.42.9-17.el7.x86_64 4/14
Installing : e2fsprogs-1.42.9-17.el7.x86_64 5/14
Updating : 1:openssl-libs-1.0.2k-19.el7.x86_64 6/14
Installing : 1:make-3.82-24.el7.x86_64 7/14
Installing : 1:openssl-1.0.2k-19.el7.x86_64 8/14
/var/tmp/rpm-tmp.8S1dKq: line 17: /dev/tty: No such device or address
error: %pre(msodbcsql17-17.5.2.1-1.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package msodbcsql17-17.5.2.1-1.x86_64
error: msodbcsql17-17.5.2.1-1.x86_64: install failed
/var/tmp/rpm-tmp.tObfQB: line 4: /dev/tty: No such device or address
error: %pre(mssql-tools-17.5.2.1-1.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package mssql-tools-17.5.2.1-1.x86_64
Installing : unixODBC-devel-2.3.7-1.rh.x86_64 11/14
error: mssql-tools-17.5.2.1-1.x86_64: install failed
Cleanup : 1:openssl-libs-1.0.2k-8.el7.x86_64 12/14
Cleanup : libss-1.42.9-10.el7.x86_64 13/14
Cleanup : libcom_err-1.42.9-10.el7.x86_64 14/14
Verifying : libss-1.42.9-17.el7.x86_64 1/14
When i run this installation command manually inside the container's terminal using docker exec then it works fine.
If i run this command directly in a linux machine it works fine.
only when i am building a docker image using docker build i am getting the error /dev/tty: No such device or address
Try:
RUN ACCEPT_EULA=Y yum install -y unixODBC-devel mssql-tools

Not able to access pip host from Google cloud build

I'm trying to create a docker image using google cloud build but it is failing to access the pip host.
below is the line I'm getting error
RUN pip install -vvv --extra-index-url http://[pip host] --trusted-host [pip host] -r requirements.txt
Step #2: Step 7/10 : RUN pip install --extra-index-url http://[pip host] --trusted-host [pip host] -r requirements.txt
Step #2: ---> Running in 1400ecddf71f2
Step #2: Looking in indexes: https://pypi.org/simple, http://[pip host]/simple/
Step #2: Collecting [some package == version](from -r requirements.txt (line 1))
Step #2: WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPConnection object at 0x7f58e9d64b70>, 'Connection to [pip host] timed out. (connect timeout=15)')': /simple/[some package]/
Step #2: WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPConnection object at 0x7f58e9d5a9e8>, 'Connection to [pip host] timed out. (connect timeout=15)')': /simple/[some package]/
Thanks in advance

Docker build on Windows failed to establish a new connection Errno 11001 getaddrinfo failed

Docker build is failing when it gets to this step:
RUN pip install -r requirements.txt
Some other answers suggested adding --dns or using a proxy server setting, but none of them work (--dns is an unknown flag).
This happens with all Docker Build commands. I have tried my home network because I though my work network is causing this error. But the same error results. And this same build command worked 2 weeks ago.
Full test of error:
C:\Users\Ghassan.Hariz\Documents\_Dev\Docker\FlaskWAHelloWorld>docker build
-f Dockerfile -t flaskhelloworld:latest .
Sending build context to Docker daemon 4.096kB
Step 1/7 : FROM python:3.6
3.6: Pulling from library/python
3889bb8d808b: Pull complete
6631c2d2a60c: Pull complete
3e7b18583f4b: Pull complete
adf62195c93f: Pull complete
41bbc8eda457: Pull complete
9dfc9d816cb9: Pull complete
a57794da6fe5: Pull complete
f06f2d6a9853: Pull complete
25a7926ec41d: Pull complete
Digest:
sha256:0dab923cf03b659a25b2f3e05181bddc11e2af4577537f5050db479882c7bd53
Status: Downloaded newer image for python:3.6
---> 0450e8af9dc3
Step 2/7 : RUN mkdir /code
---> Running in 75c6959f8ee9
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/30/2018 7:00 AM code
Removing intermediate container 75c6959f8ee9
---> 419d2d14684f
Step 3/7 : WORKDIR /code
Removing intermediate container cdcdcbe7f3fa
---> fcdc1433a9a6
Step 4/7 : ADD . /code/
---> 031143926f8f
Step 5/7 : RUN pip install -r requirements.txt
---> Running in a3219ca48077
Collecting Flask (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection
object at 0x00000222AFB46908>: Failed to establish a new connection: [Errno
11001] getaddrinfo failed',)': /simple/flask/
Retrying (Retry(total=3, connect=None, read=None, redirect=None,status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000222AFB467F0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/flask/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000222AFB46518>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/flask/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000222AFB46860>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/flask/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000222AFB464E0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/flask/
Could not find a version that satisfies the requirement Flask (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for Flask (from -r requirements.txt (line 1))
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; pip install -r requirements.txt' returned a non-zero code: 1
C:\Users\Ghassan.Hariz\Documents_Dev\Docker\FlaskWAHelloWorld>docker --version
Docker version 18.06.1-ce, build e68fc7a

Resources