top of page

Unlocking Ultra-Fast Python Builds in Docker with UV

  • Writer: Ankur Jain
    Ankur Jain
  • May 13
  • 3 min read


Building efficient and reliable Docker images is a critical part of modern Python development, but traditional tooling often introduces unnecessary overhead. Whether you’re managing dependencies with Pip or orchestrating complex environments with Poetry, the time it takes to install packages can become a bottleneck in CI/CD pipelines and local workflows alike.


UV, a blazing-fast Python package manager developed by the team behind Ruff, offers a compelling solution. Written in Rust and designed for speed, UV consolidates multiple Python tooling functions like package installation, dependency resolution, and virtual environment management into a single streamlined binary. This article explores UV’s impact on Docker build performance, its growing adoption in the Python ecosystem, and how it compares to existing tools like Pip.


If you’re looking for a deeper technical breakdown of UV’s architecture and full capabilities beyond Docker-focused workflows, check out the comprehensive guide from SaaS Pegasus.


What Makes UV Different?

UV is designed from the ground up to be fast, modern, and highly integrated. Here’s what sets it apart:


  1. Performance That Speaks Volumes

    UV delivers installation speeds 10–100x faster than Pip and Poetry in various benchmarks. Its Rust-based core, parallel download capabilities, and optimised dependency resolver eliminate the sluggishness developers often encounter with Pip.


  2. All-in-One Tooling

    UV consolidates the functionality of multiple Python tools into a single binary:

    1. pip – package installation

    2. pip-tools – dependency locking

    3. virtualenv – environment management

    4. pyenv – python version management

    5. poetry – project structure

    6. pipx – CLI tool isolation


  3. Built-In Virtual Environments

    UV automatically creates and manages isolated environments (typically under .venv), reducing the need for manual setup or external tools.


  4. Modern Configuration Standards

    It uses pyproject.toml for configuration and introduces uv.lock for reproducible builds. It supports dependency groups (e.g., dev, prod) and version overrides for granular control.


  5. Python Version Management

    UV can install and manage Python versions per project, eliminating the need for pyenv. A Python version file specifies which interpreter to use, ensuring consistent environments across systems.


  1. CLI Tool Management with UV tool

    Install and run CLI tools like Black or Ruff in isolated contexts without polluting your project environment.



UV vs. Pip: The Speed Revolution

For years, Pip has been the go-to package installer for Python, driving the ecosystem’s growth and accessibility. However, its performance limitations ,  particularly in speed ,  have become increasingly noticeable in modern development environments. UV outperforms Pip in nearly every benchmark, offering a significant speed boost. For example, installing Pandas with UV took just 1.216 seconds, compared to 2.624 seconds with Pip. In tests without caching, UV is 8 to 10 times faster, and with a warm cache, it’s an incredible 80 to 115 times quicker. Streamlit Cloud saw a 55% reduction in app deployment time after switching from pip to UV, with installation times dropping from 60 seconds to just 20.


Let’s See UV in Action with Docker Builds


We’ll demonstrate UV’s impact on Docker build times by comparing two Dockerfiles - one using the standard Pip and the other with UV.


Here is the requirements.txt file that contains the required packages we would like to install in Docker.

numpy==2.2.4
pandas==2.2.3
python-dotenv==1.1.0
pyarrow==19.0.1
apache-airflow==2.10.5
sqlalchemy==1.4.54
psycopg2-binary==2.9.10
dbt-core==1.9.4
dbt-postgres==1.9.0
boto3==1.37.28
google-cloud-bigquery==3.31.0
snowflake-connector-python==3.14.0
delta-spark==3.3.0
duckdb==1.2.1
deltalake==0.25.5

Dockerfile Without UV

FROM python:3.11-bullseye

ENV APP_HOME /app
WORKDIR $APP_HOME


COPY requirements.txt /app

# Install dependency packages
RUN pip install --no-cache-dir -r requirements.txt

COPY ./src /app


The build time for this Dockerfile was 116.9 seconds to install all the required dependencies with a total build time of 150.9 seconds.


Dockerfile With UV

FROM python:3.11-bullseye
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV APP_HOME /app
WORKDIR $APP_HOME

ENV VIRTUAL_ENV=/usr/local

COPY requirements.txt /app

# Install dependency packages
RUN uv pip install --system --no-cache-dir -r requirements.txt

COPY ./src /app


Using UV, the total build time is reduced significantly to 79.9 seconds, with dependency installation taking just 52.2 seconds - effectively cutting the overall time by nearly half.


The substantial speed boost offered by UV isn’t just a small improvement - it can transform how quickly developers set up and manage python environments, especially for large projects. Reducing installation times from minutes to seconds enhances productivity, minimises CI/CD waiting times, and accelerates experimentation cycles, enabling a more agile development approach. While pip’s long history makes it a staple in the python ecosystem, UV’s performance and modern features offer compelling reasons for developers to switch, addressing pip’s recognised limitations and offering a tangible incentive for adoption.



A Smarter Future for Python Packaging

UV isn’t just faster, it’s a smarter, more modern way to manage python projects. By addressing pip’s performance gaps and simplifying the dev experience, UV is quickly becoming a go-to tool for teams that care about speed and reliability. Its rise reflects a broader shift in the python ecosystem toward better tooling. If you’re looking to optimise Docker builds or just cut friction from your workflow, UV is a clear step forward.


To learn more about how Innablr can help with your data needs, feel free to reach out to us.

bottom of page