DEV Community

Utkarsh
Utkarsh

Posted on

🐳 Using docker for DL MLOps for the first time

For the past few weeks, I’ve been on a personal 30-day MLOps challenge to get hands-on with tooling and workflows used in real-world machine learning deployments. As part of this challenge, I containerized my first deep learning solution using Docker. The experience was both educational and practical — and this post breaks it all down.

🔧 The Project: Predicting Wine Quality Using Keras

The goal was to create a regression model that predicts the quality of white wine based on its chemical properties.

Here's a snapshot of what the project involved:

  • Dataset: UCI White Wine Quality dataset
  • Model: Keras Sequential ANN with one hidden layer
  • Evaluation: Root Mean Squared Error (RMSE)
  • Experiment Tracking: MLflow
  • Hyperparameter Optimization: Hyperopt
  • Infrastructure: Docker + DVC + Git + MLflow UI

❓ Why Docker?

I’ve always heard that Docker makes ML workflows easier, but this was the first time I actually saw the benefits:

  • Reproducibility without “it works on my machine” issues
  • Environment isolation for TensorFlow, Pandas, and Scikit-learn
  • Easy handoff to others or future-me without setup headaches
  • Version-controlled build steps, just like code

Deep learning often involves specific versions of CUDA, TensorFlow, and Python. Docker let me lock those down cleanly.


📁 Project Structure

Here's what my final directory looked like:

wine-quality/ ├── Dockerfile ├── requirements.txt ├── train.py ├── data/ │ └── winequality-white.csv ├── models/ │ └── model.pkl ├── mlruns/ # MLflow tracking └── README.md 
Enter fullscreen mode Exit fullscreen mode

I kept everything modular and reproducible, even though it was a single-user project.

🧠 Key Docker Learnings (from a Deep Learning Perspective)

1. Deep Learning images need extra care

  • TensorFlow and Keras are heavier than most ML packages
  • I used tensorflow/tensorflow:2.13.0 as a base image
  • GPU usage requires nvidia-docker, CUDA, and cuDNN (I stuck to CPU for simplicity)

2. Dependencies stay locked

  • My requirements.txt included: keras, mlflow, numpy, scikit-learn, hyperopt
  • Docker recreated the exact same environment every time

3. MLflow UI inside a container is so helpful

  • Exposed MLflow's web UI at localhost:5000
  • Compared experiment runs visually across different hyperparameter sweeps

4. Reproducibility felt real

  • After the image was built, everything worked out of the box
  • I didn’t have to reinstall libraries or fix version mismatches

🐳 Dockerfile Breakdown

Here’s a simplified version of my Dockerfile:

FROM tensorflow/tensorflow:2.13.0 WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["python", "train.py"] 
Enter fullscreen mode Exit fullscreen mode

Simple, readable, and effective.

🚀 Running the Project

I built and ran the container in two simple steps:

docker build -t wine-ml . docker run -p 5000:5000 wine-ml 
Enter fullscreen mode Exit fullscreen mode

The container did the following:

  • Pulled in the wine dataset
  • Ran hyperparameter optimization using Hyperopt
  • Logged all runs and models to MLflow
  • Printed the best run’s RMSE and corresponding hyperparameters

📊 Experiment Tracking with MLflow

Inside the container, I used MLflow to:

  • Log learning rate and momentum values
  • Track RMSE for each training run
  • Save Keras models using mlflow.tensorflow.log_model

This was the first time I combined MLflow with Docker, and it worked seamlessly. I exposed the MLflow tracking server from inside the container to my local browser using the -p 5000:5000 flag.

🧰 Other Tools That Helped

  • DVC: For tracking the dataset and maintaining reproducibility
  • Git + GitHub: For version control of code and .dvc pointers
  • Hyperopt: For searching hyperparameter space efficiently
  • VSCode Dev Containers: Helped with debugging and development inside Docker

💡 Key Takeaways

  • Docker is incredibly helpful for DL projects, even more than I expected.
  • The ability to isolate a full TensorFlow/Keras environment and still run MLflow experiments was a huge win.
  • Deep learning containers require a bit more setup (especially GPU configs), but for CPU-based work, it’s pretty much plug-and-play.
  • Reproducibility isn’t just a buzzword — once I used Docker and DVC together, every experiment felt fully trackable.
  • MLflow inside Docker is a hidden gem. It’s lightweight and super effective for solo or team-based projects.

🧭 What's Next

As I continue this 30-day MLOps challenge, I’m planning to:

  • Add Docker Compose to spin up a full ML stack (training + tracking + monitoring)
  • Explore model serving with mlflow models serve inside Docker
  • Try GPU acceleration using nvidia-docker
  • Push models and metrics to DagsHub for web-based experiment tracking

✅ Final Thoughts

If you’re learning MLOps or building deep learning projects for the first time, don’t wait to try Docker. It will:

  • Save you hours debugging environments
  • Help you collaborate more cleanly
  • Make your project production-ready from day one

This project showed me how Docker wasn’t just helpful — it was essential.

🙋 Looking for Guidance

I’m still just getting started in MLOps and deep learning infrastructure.

If you're experienced with model serving, deployment best practices, or advanced MLOps tooling, I'd love to learn from you.

Feel free to drop feedback or connect — I'm genuinely looking for guidance and mentorship from folks who've walked this path.


Thanks for reading!

If you’re on your own MLOps journey or want to swap notes, let’s connect.

I’ll be posting more learnings from this 30-day challenge soon.

Top comments (0)