9

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.

Donato Perconti
  • 814
  • 2
  • 11
  • 28
  • Where are you running `which pip` from? Does `bin/pip` exist in the same directory as your Dockerfile? – jwodder Aug 22 '16 at 17:56
  • I'm assuming pip is being run from ../myapp/bin/pip, so, yes, it's in the same directory as my Dockerfile. I will update the question with relevant file structure. – Donato Perconti Aug 22 '16 at 17:58
  • If `pip` is not contained by the same directory as your Dockerfile (i.e., in the same directory or in a subdirectory thereof), it's nothing that will be available inside the container. The fact that you show pip as being in `../myapp/bin` suggests that this is your problem. Consider truncating your Dockerfile to just the `FROM` and `ADD` statements, then booting a shell in the resulting image and checking to see if things look like you expect. – larsks Aug 22 '16 at 18:18
  • myapp is the root folder. Sorry for the confusion. I have updated the question to display the file structure as well as the contents of the Dockerfile. – Donato Perconti Aug 22 '16 at 18:26
  • can you post your complete dockerfile? – Woot4Moo Aug 24 '16 at 19:10
  • @Woot4Moo, the `FROM amazon/aws-eb-python:3.4.2-onbuild-3.5.1` is all that is on there. – Donato Perconti Aug 24 '16 at 19:11
  • apologies, I missed that on the read through. – Woot4Moo Aug 24 '16 at 19:25
  • I not get it, `which pip` command you type where? inside `docker` container, or inside OS where you build docker image? – fghj Aug 24 '16 at 20:04
  • You are running pip command in docker image, I think the path of pip should be /bin/pip. – neohope Aug 25 '16 at 05:14

3 Answers3

5

Something is very odd here. Why do you have the virtualenv content next to your Dockerfile? The image you are building from creates the virtualenv on /var/app (within the container, yes?) for you. I believe that the ONBUILD command copies it (or parts of it) over and corrupt the rest of the process, making the /var/app/bin/pip inoperable.

FROM       python:3.4.2 <-- this is the base image, on top of which the following command will be applied

WORKDIR    /var/app <-- this is the working dir (a la 'cd /var/app')

RUN        pip3 install virtualenv <-- using pip3 (installed using base image I presume) to install the virtualenv package
RUN        virtualenv /var/app <-- creating a virtual env on /var/app
RUN        /var/app/bin/pip install --download-cache /src uwsgi <-- using the recently install virtualenv pip to install uwsgi

...

ONBUILD    ADD . /var/app <-- add the contents of the directory where the Dockerfile is built from, I think this is where the corruption happen 
ONBUILD    RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -r /var/app/requirements.txt; fi <-- /var/app/bin/pip has beed corrupted

You should not care about externally having /var/app available on the host. You just need (based on the Dockerbuild file) have the "requirements.txt" available on the host, to be copied into the container (or not, if not, it will skip).

creativeChips
  • 1,177
  • 9
  • 12
  • the virtualenv contents are there because I am switching over an existing project. Regardless, I removed all other docker content and virtualenv and started fresh with the docker implementation. I'm running into different issues but I am passed the above issue. Thanks for the help. – Donato Perconti Aug 29 '16 at 15:41
1

/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.

alper
  • 2,919
  • 9
  • 53
  • 102
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
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
│      .
.
Santanu Dey
  • 2,900
  • 3
  • 24
  • 38