← All insightsCheat Sheet

MLflow cheat sheet: the complete command reference

CodeWizard Engineering · 24 September 2025 · 3 min read · Beginner

This is a complete, hands-on MLflow cheat sheet: install, configure, operate, automate and secure it - with copy-paste commands grouped by task. Bookmark it for day-to-day work, incidents and interviews alike.

MLflow tracks ML experiments (params, metrics, artifacts), packages models, and provides a model registry with stages - bringing DevOps-style versioning and reproducibility to machine learning.

Why you reach for it

  • Reproducible experiments with tracked params and metrics
  • A model registry with staging/production promotion
  • Framework-agnostic packaging and serving

Installation

bash
pip install mlflow
mlflow server --host 0.0.0.0 --port 5000 --backend-store-uri sqlite:///mlflow.db

Configuration reference

Track a run and log a model.

python
import mlflow
mlflow.set_tracking_uri('http://localhost:5000')
with mlflow.start_run():
    mlflow.log_param('lr', 0.01)
    mlflow.log_metric('accuracy', 0.94)
    mlflow.sklearn.log_model(model, 'model', registered_model_name='fraud')

Core commands you use daily

bash
mlflow models serve -m 'models:/fraud/Production' -p 5001
curl -X POST http://localhost:5001/invocations -H 'Content-Type: application/json' -d '{"inputs": [[1,2,3]]}'

Server & tracking

bash
mlflow server --host 0.0.0.0 --port 5000 --backend-store-uri postgresql://... --artifacts-destination s3://mlflow
export MLFLOW_TRACKING_URI=http://localhost:5000
mlflow experiments create -n fraud

Models & serving

bash
mlflow models serve -m 'models:/fraud/Production' -p 5001
mlflow models build-docker -m models:/fraud/Production -n fraud:latest
curl -X POST http://localhost:5001/invocations -H 'Content-Type: application/json' -d '{"inputs": [[1,2,3]]}'

Use it in CI/CD

Log evaluation metrics from a training pipeline.

yaml
- run: |
    python train.py            # logs params/metrics to MLflow
    mlflow models build-docker -m models:/fraud/Production -n fraud:latest

Best-practice checklist

  • Use a database backend + object storage for artifacts
  • Gate registry promotion on evaluation metrics
  • Version data and code alongside the model run

Common pitfalls to avoid

  • Using the local file store in production instead of a real backend
  • No artifact store, so large models are lost
  • Promoting models to Production without an evaluation gate

Security quick wins

  • Put the tracking server behind auth and TLS
  • Restrict who can promote models to Production

Works well with

  • Kubeflow - The ML toolkit for Kubernetes - pipelines, training operators and model serving on your cluster.
  • Python for DevOps - The glue language of DevOps - automation scripts, CLIs, API clients and operators.
  • Kubernetes - Declarative orchestration for containers at scale - self-healing, rolling updates and service discovery.
A cheat sheet is muscle memory on paper - keep it close until the commands live in your fingers.

Want senior help putting MLflow to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult