'Docker Build can't find pip
Trying to follow a few[1][2] simple Docker tutorials via AWS am and getting the following error:
> docker build -t my-app-image .
Sending build context to Docker daemon 94.49 MB
Step 1 : FROM amazon/aws-eb-python:3.4.2-onbuild-3.5.1
# Executing 2 build triggers...
Step 1 : ADD . /var/app
---> Using cache
Step 1 : RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi
---> Running in d48860787e63
/bin/sh: 1: /var/app/bin/pip: not found
The command '/bin/sh -c if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi' returned a non-zero code: 127
Dockerfile:
# For Python 3.4
FROM amazon/aws-eb-python:3.4.2-onbuild-3.5.1
Which pip returns the following:
> which pip
./bin/pip
Relevant file structure:
.
├── Dockerfile
├── bin
│ ├── activate
│ ├── pip
│ ├── pip3
│ ├── pip3.5
│ ├── python -> python3
│ ├── python-config
│ ├── python3
│ ├── python3.5 -> python3
│ .
.
Again, noob in all things Docker so I'm not sure what troubleshooting steps to take. Please let me know what other helpful information I can provide.
Solution 1:[1]
I think the issue is how you have organized your bin/pip files
From Docker Documentation: https://docs.docker.com/engine/reference/builder/#add
If <dest> does not end with a trailing slash, it will be considered a regular file and the contents of <src> will be written at <dest>.
So your file structure should be :
.
??? Dockerfile
??? app
| |__bin
| | |
? ??? activate
? ??? pip
? ??? pip3
? ??? pip3.5
? ??? python -> python3
? ??? python-config
? ??? python3
? ??? python3.5 -> python3
? .
.
Solution 2:[2]
/var/app/bin/pip suppose to work because the amazon/aws-eb-python:3.4.2-onbuild-3.5.1 Dockerfile includes:
RUN pip3 install virtualenv
RUN virtualenv /var/app
RUN /var/app/bin/pip install --download-cache /src uwsgi
It means when you are using this image as a base image, its two ONBUILD instructions would apply to your current build.
ONBUILD ADD . /var/app
ONBUILD RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi
Try with a simpler Dockerfile, and open a shell session from it, in order to check if /var/app is there, and if pip is correctly installed.
You could also test rebuilding directly the 3.4.2-aws-eb-onbuild image itself, again for testing.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Santanu Dey |
| Solution 2 | alper |
