Docker Community Forums

Share and learn in the Docker community.

Unable to run flask app

Hi Everyone need some help here
os:Windows 10
docker:docker toolbox for windows runing on oracle Virtual box

hi Guys below is the the docker file i am using

FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential

COPY ./requirements.txt /app/requirements.txt

WORKDIR /app

RUN pip install -r requirements.txt

RUN [“chmod”, “+x”, “app.py”]

COPY . /app

ENTRYPOINT [ “python” ]

CMD [“app.py” ]

i am facing two issues here trying to build the image on docker tool box
1.
the below warning
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have ‘-rwxr-xr-x’ permissions. It is recommended to double check and reset permissions for sensitive files and directories.

how to get rid of that issue.

i have tried adding chmod in above docker file

  1. if i remove the chmod in the above file
    i am getting other error in flask like below

if name==“main”:
app.run(debug=True, port=‘8080’, host=‘0.0.0.0’)

Traceback (most recent call last):
File “Flask_application.py”, line 82, in
app.run(debug=True)#, port=‘8080’, host=‘0.0.0.0’)
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 943, in run
run_simple(host, port, self, **options)
File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 988, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File “/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py”, line 332, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
File “/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py”, line 176, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ, close_fds=False)
File “/usr/lib/python2.7/subprocess.py”, line 172, in call
return Popen(*popenargs, **kwargs).wait()
File “/usr/lib/python2.7/subprocess.py”, line 394, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1047, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

Nagendra@DESKTOP-4A89RHD MINGW64 ~/Desktop/demo
$ docker run suspect_flask:v2.0

  • Serving Flask app “Flask_application” (lazy loading)
  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
    Traceback (most recent call last):
    File “app.py”, line 82, in
    app.run(debug=True)#, port=‘8080’, host=‘0.0.0.0’)
    File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 943, in run
    run_simple(host, port, self, **options)
    File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
    File “/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py”, line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
    File “/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py”, line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
    File “/usr/lib/python2.7/subprocess.py”, line 172, in call
    return Popen(*popenargs, **kwargs).wait()
    File “/usr/lib/python2.7/subprocess.py”, line 394, in init
    errread, errwrite)
    File “/usr/lib/python2.7/subprocess.py”, line 1047, in _execute_child
    raise child_exception
    OSError: [Errno 8] Exec format error

could someone please help how to fix these issues.