Newbie needs handholding

Hi all,
Obviously something fundamental I’m missing here. I was going through the basic training materials and bulding the first python flask.app (display cat pictures. All went ok until the actual “docker run”, where I received error messages thus:

container_linux.go:247: starting container process caused “exec: "app.py": executable file not found in $PATH”
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused “exec: "app.py": executable file not found in $PATH”.

After a bit of checking and rebuilding with no joy I went back to basics, did an interactive “docker run -it alpine:3.5 /bin/sh” (alpine:3.5 being the “FROM” from Dockerfile) and looked around for python. Not installed. Now I realise I might be confused but I am !

If it’s relevant, running on Ubuntu 16.04

Anything appreciated

Kind regards

Hard to say without looking at the Dockerfile, but I’d guess you’re trying something like ENTRYPOINT ["app.py"] without having the executable anywhere in $PATH, like the message says. You probably want to update to something like ENTRYPOINT ["python", "app.py"] or ENTRYPOINT ["/app.py"] if it has the executable bits set for permissions and references #!/bin/python.

Hi, thanks for the reply

Famous last words, but I reran this morning to get info for the post, didn’t do anything different … and it worked.

More info below FYI:

Dockerfile

FROM alpine:3.5

RUN apk add --update py2-pip

COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt

COPY app.py /usr/src/app/
COPY templates/index.html /usr/src/app/templates/

EXPOSE 5000

CMD [“python”, “/usr/src/app/app.py”]

requirements.txt
Flask==0.10.1

app.py
from flask import Flask, render_template
import random

app = Flask(name)

images = [
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr05/15/9/anigif_enhanced-buzz-26388-1381844103-11.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr01/15/9/anigif_enhanced-buzz-31540-1381844535-8.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr05/15/9/anigif_enhanced-buzz-26390-1381844163-18.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr06/15/10/anigif_enhanced-buzz-1376-1381846217-0.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr03/15/9/anigif_enhanced-buzz-3391-1381844336-26.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr06/15/10/anigif_enhanced-buzz-29111-1381845968-0.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr03/15/9/anigif_enhanced-buzz-3409-1381844582-13.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr02/15/9/anigif_enhanced-buzz-19667-1381844937-10.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr05/15/9/anigif_enhanced-buzz-26358-1381845043-13.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr06/15/9/anigif_enhanced-buzz-18774-1381844645-6.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr06/15/9/anigif_enhanced-buzz-25158-1381844793-0.gif”,
http://ak-hdl.buzzfed.com/static/2013-10/enhanced/webdr03/15/10/anigif_enhanced-buzz-11980-1381846269-1.gif
]
@app.route(‘/’)
def index():
url = random.choice(images)
return render_template(‘index.html’, url=url)

if name == “main”:
app.run(host=“0.0.0.0”)

Build

docker build -t myname/myfirstapp .

Sending build context to Docker daemon 7.68 kB
Step 1/8 : FROM alpine:3.5
—> 88e169ea8f46
Step 2/8 : RUN apk add --update py2-pip
—> Using cache
—> 7a06f9db1008
Step 3/8 : COPY requirements.txt /usr/src/app/
—> Using cache
—> 35cf99f03bbb
Step 4/8 : RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt
—> Using cache
—> 52c17c28961d
Step 5/8 : COPY app.py /usr/src/app/
—> Using cache
—> 9dc64b8702e3
Step 6/8 : COPY templates/index.html /usr/src/app/templates/
—> Using cache
—> 539c5c8908a0
Step 7/8 : EXPOSE 5000
—> Using cache
—> ff5d678c78c6
Step 8/8 : CMD python /usr/src/app/app.py
—> Using cache
—> c07c7017b381
Successfully built c07c7017b381

Finally run

docker run -p 8888:5000 --name myfirstapp myname/myfirstapp

  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    172.17.0.1 - - [22/Feb/2017 09:40:17] “GET / HTTP/1.1” 200 -
    172.17.0.1 - - [22/Feb/2017 09:40:22] “GET /favicon.ico HTTP/1.1” 404 -
    172.17.0.1 - - [22/Feb/2017 09:40:45] “GET / HTTP/1.1” 200 -