How-to
Manual Docker Build Guide
This is a reproducible Docker source project. It isn't an already-built Docker image. A Docker image is created when docker compose build succeeds on your computer.
1. Verify Docker Desktop on Your Mac#
Open Docker Desktop and wait until the engine is running. Then open Terminal.
docker --version
docker compose version
docker info
If docker info fails, Docker Desktop isn't ready. If Docker can't be found, open/reinstall Docker Desktop.
2. Get the Project Folder#
From GitHub (your GitHub account needs access to the private repository):
git clone https://github.com/domail2karandeshmukh-cyber/group6-kc1-defect-prediction.git
cd group6-kc1-defect-prediction
ls
From a ZIP: double-click the ZIP in Finder. In Terminal, type cd (with a space), drag the extracted project folder onto the Terminal window, press Enter, then run ls.
You should see Dockerfile, compose.yaml, requirements.txt, train.py, api_app.py, streamlit_app.py.
3. Two Ways to Build#
Method A: one command (fast demo)
bash scripts/start_mac.sh
The script runs exactly the Method B commands and checks the API.
Method B: manual steps (best for learning and demonstrating)
docker compose build
This builds image group6-kc1:latest using Dockerfile: Python 3.11, required packages, and application files.
docker image ls group6-kc1
This lists the built image; it doesn't yet mean the application is running.
docker compose --profile train run --rm trainer
This downloads the KC1 dataset if it isn't already present, deduplicates it, fits the four classifiers, logs runs to MLflow, evaluates thresholds and GMM models, then exports the selected model to artifacts/.
docker compose up -d
This starts the API, UI, and MLflow containers. The -d flag runs them in the background.
docker compose ps
This lists running containers and their status.
bash scripts/verify_mac.sh
This checks the image, containers, endpoint responses, and a sample prediction.
4. Open the Three Interfaces#
| Service | Local URL | Purpose |
|---|---|---|
| Streamlit | http://localhost:8501 |
Enter the 21 code metrics and select Predict defect |
| FastAPI / Swagger | http://localhost:8000/docs |
Demonstrate GET /health and POST /predict |
| MLflow | http://localhost:5000 |
Show tracked classifier, threshold, and GMM runs |
5. What to Show the Teacher#
Dockerfile: explain base Python image, installing packages, copying source, default command.compose.yaml: explain four services: trainer (on demand), API, Streamlit UI, MLflow viewer.docker image ls group6-kc1: proves image exists after it has been built.docker compose ps: proves services are running.http://localhost:8000/healthandhttp://localhost:8000/docs: API reachable.http://localhost:8501: select Load KC1 sample and Predict defect; read the result.http://localhost:5000: show experiments and model metrics.
Take screenshots of your actual run, not simulated screenshots.
6. Troubleshooting#
docker: command not found→ Ensure Docker Desktop installed and CLI accessible.- Docker daemon unavailable → Start Docker Desktop and wait for engine startup.
- KC1 dataset fetch fails → Download
kc1.csvusing your browser from the source URL intrain.py, put it atartifacts/kc1.csv, rerun trainer. - Trainer prints unknown labels/feature names → Check dataset is truly NASA/PROMISE KC1 CSV, not another project.
- Port 8000/8501/5000 is busy → Shut down other locally running services, or change the left port in compose.yaml. Keep container port unchanged.
- API cannot load model → Run the trainer successfully first; confirm
artifacts/kc1_defect_pipeline.joblibexists. - UI cannot reach API →
docker compose logs apianddocker compose logs ui. - Rerun training →
docker compose --profile train run --rm trainerthendocker compose restart api ui. - Stop containers →
docker compose down.
7. Image Export / Docker Hub#
If the teacher explicitly asks for a transferable image rather than files to build it:
docker save -o Group6_KC1_Docker_Image.tar group6-kc1:latest
This produces a large image archive on your Mac after the build (309 MB for the team's build). The source code is much smaller and is not the same thing as an exported image. The .tar isn't stored in GitHub; share it separately. On another computer, load it with:
docker load -i Group6_KC1_Docker_Image.tar
A docker push to Docker Hub is a separate step that needs a Docker Hub account and explicit permission to publish. The exact commands are in README.md, section Sharing the Docker image.
8. Recreate the Docker Packaging Manually#
If you want to reproduce rather than simply run the supplied files:
- Start from your KC1 project Python sources and trained artifacts.
- Create
requirements.txtlisting the imports needed at runtime. - Create
Dockerfile:FROM python:3.11-slim; setWORKDIR /app;COPYrequirements;RUN pip install;COPYapp files;CMDlaunch Uvicorn. - Create
compose.yamlwith one image reused fortrainer,api,ui,mlflow; mount a persistent./artifactsfolder; expose ports 8000, 8501 and 5000 to localhost. - Build with
docker compose build, train, start services, and test. - Save screenshots and summarize the architecture in your own words.
Why the trainer runs separately: You generally want to train once, then reuse the saved model for as many API predictions as you want; the API shouldn't retrain every time it starts.
Important experimental limitation: Model and threshold selection in this classroom project use the held-out test set, which can bias reported performance. Production workflows should choose models and thresholds with validation data and reserve the test set for final evaluation.
AI use: It's fine to study this code and use assistance where allowed. Follow your teacher's rules on attribution. Don't claim to have manually built and verified a Docker image until you actually run the build and tests.