cyberark / KubiScan

A tool to scan Kubernetes cluster for risky permissions
GNU General Public License v3.0
1.31k stars 130 forks source link

Dependecy issue in the Dockerfile in pip requirements. Can't build the docker image. #57

Closed MMquant closed 1 year ago

MMquant commented 1 year ago

What happened (please include outputs or screenshots):

There is a dependecy issue in the Dockerfile in pip requirements. The docker image cannot be built.

$ docker build -t kubiscan .
Sending build context to Docker daemon  8.144MB
Step 1/12 : ARG DOCKER_REGISTRY=index.docker.io
Step 2/12 : ARG PYTHON_IMAGE=${DOCKER_REGISTRY}/python:3.8.0-slim-buster
Step 3/12 : FROM ${PYTHON_IMAGE} AS build-image
3.8.0-slim-buster: Pulling from library/python
000eee12ec04: Pull complete 
ddc2d83f8229: Pull complete 
3ae1660fa0d9: Pull complete 
ef709117d3d3: Pull complete 
487a0421e8fa: Pull complete 
Digest: sha256:8e243f41e500238f78f7a29a81656114d3fe603d5c34079a462d090f71c4b225
Status: Downloaded newer image for python:3.8.0-slim-buster
 ---> 577b86e4ee11
Step 4/12 : WORKDIR /tmp/build-kubiscan
 ---> Running in fa152e3fc358
Removing intermediate container fa152e3fc358
 ---> bddd52bfd7d8
Step 5/12 : COPY requirements.txt requirements.txt
 ---> ee687ab1ba46
Step 6/12 : RUN pip3 install -r requirements.txt
 ---> Running in d77da43ddcf6
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 0x7f35eebdf490>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/kubernetes/
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 0x7f35eebdf9a0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/kubernetes/
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 0x7f35eebdf7f0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/kubernetes/
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 0x7f35eebdf580>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/kubernetes/
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 0x7f35eebdf2e0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/kubernetes/
ERROR: Could not find a version that satisfies the requirement kubernetes==11.0.0 (from -r requirements.txt (line 1)) (from versions: none)
ERROR: No matching distribution found for kubernetes==11.0.0 (from -r requirements.txt (line 1))
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

What you expected to happen:

Build the kubiscan docker image.

How to reproduce it (as minimally and precisely as possible):

Tested on repository with the latest commit b8e7f427692953d59284eb8d23033371c9026bdb Clone the repo and run

$ docker build -t kubiscan .

Anything else we need to know?:

Environment:

Docker version 20.10.12, build 20.10.12-0ubuntu2~20.04.1
Linux ubuntu 5.15.0-56-generic
g3rzi commented 1 year ago

Thanks, we will check it

g3rzi commented 1 year ago

I checked it now and it worked, I wasn't able to reproduce the bug:

Step 6/12 : RUN pip3 install -r requirements.txt
 ---> Running in eb68cd564a4d
Collecting kubernetes==11.0.0
  Downloading https://files.pythonhosted.org/packages/59/46/d4b9364fcab59b5f9248e014c7592df8de84ad6548a6fe3de2d805bb75fc/kubernetes-11.0.0-py3-none-any.whl (1.5MB)
Collecting PTable==0.9.2
  Downloading https://files.pythonhosted.org/packages/ab/b3/b54301811173ca94119eb474634f120a49cd370f257d1aae5a4abaf12729/PTable-0.9.2.tar.gz
Collecting urllib3>=1.24.2
  Downloading https://files.pythonhosted.org/packages/65/0c/cc6644eaa594585e5875f46f3c83ee8762b647b51fc5b0fb253a242df2dc/urllib3-1.26.13-py2.py3-none-any.whl (140kB)
Collecting requests

It seems that it can't find the package kubernetes==11.0.0:

ERROR: Could not find a version that satisfies the requirement kubernetes==11.0.0 (from -r requirements.txt (line 1)) (from versions: none)
ERROR: No matching distribution found for kubernetes==11.0.0 (from -r requirements.txt (line 1))

Can you try to change the requirement.txt to kubernetes instead of kubernetes==11.0.0 and see if it works?

MMquant commented 1 year ago

Solution

$ service docker restart

References and more solutions

https://stackoverflow.com/questions/28668180/cant-install-pip-packages-inside-a-docker-container-with-ubuntu

g3rzi commented 1 year ago

Cool, thank you for sharing :)