Overview This tiny demo shows how to train an Iris classifier with scikit-learn, serve it with Streamlit for an interactive UI, and package it in Docker.
Files
src/train.py— trains a RandomForest and savesmodels/model.joblib.src/app.py— Flask inference API with/predictand/health.requirements.txt— Python dependencies.Dockerfile— container image.
Quickstart (PowerShell on Windows)
-
Create a Python venv and install dependencies (optional but recommended): python -m venv .venv ..venv\Scripts\Activate.ps1 pip install -r requirements.txt
-
Train the model locally: python .\src\train.py
After this you should have
models\model.joblib. -
Build the Docker image: docker build -t iris-demo:latest .
-
Run the container (recommended — bind to localhost so it's only reachable from your machine): docker run --rm -p 127.0.0.1:8501:8501 iris-demo:latest
Then open in your browser: http://127.0.0.1:8501
If you need to expose to the LAN (other devices on your network), use: docker run --rm -p 8501:8501 iris-demo:latest and open: http://:8501
Notes
- To train inside Docker during build, add
RUN python src/train.pyto the Dockerfile and copy onlysrc/before that. This makes builds longer but is reproducible.