我已经创建
这里是我的代码
app.py
import os
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
return "Welcome!"
@app.route('/how are you')
def hello():
return 'I am good, how about you?'
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port=8080)
requirements.txt
Flask
Dockerfile
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]
然后我制作图像
docker build . -t dede-flask:latest
但是我在运行脚本时遇到了错误
docker run dede-flask:latest
我出错了
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "app.py", line 14, in <module>
app.run(debug=True, host="0.0.0.0", port=8080)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 944, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 1007, 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
docker run -d -p 5000:5000 dede-flask:latest
我遇到错误
docker: Error response from daemon: driver failed programming external connectivity on endpoint friendly_bhaskara (990535df1272811a3991c8a11e06476267e027484b850c244ca195e9d5b8a220): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:5000:tcp:172.17.0.2:5000: input/output error.