Deploying a simple machine learning model to an AWS ec2 instance using flask and docker.
Serving a simple machine learning model as a webservice using flask and docker.
python app.py
to run the flask app.0.0.0.0:80
to get a message Hello World!
displayed. NOTE: A permission error may be received at this point. In this case, change the port number to 5000 in app.run()
command in app.py
.
(Port 80 is a privileged port, so change it to some port that isn't, eg: 5000)2
for the model file provided in this repo: curl -X POST \
0.0.0.0:80/predict \
-H 'Content-Type: application/json' \
-d '[5.9,3.0,5.1,1.8]'
docker build -t app-iris .
to build the docker image using Dockerfile
. (Pay attention to the period in the docker build command)docker run -p 80:80 app-iris
to run the docker container that got generated using the app-iris
docker image. (This assumes that the port in app.py is set to 80)2
for the model file provided in this repo:
curl -X POST \
0.0.0.0:80/predict \
-H 'Content-Type: application/json' \
-d '[5.9,3.0,5.1,1.8]'
For details on floating the containerized app on AWS ec2 instance, see the blog.
See LICENSE for details.