Developers should build your Docker image using uv.lock. Using the lockfile ensures your container installs the exact package versions and hashes you tested locally, rather than resolving fresh versions that could introduce unexpected bugs. Best Practices for Using uv.lock in Docker: • Enforce the lockfile during builds. Use uv sync --locked (or --frozen) in your Dockerfile. The --locked flag is recommended for production because it causes the build to fail immediately if uv.lock is out of sync with pyproject.toml, preventing silent dependency changes. • Cache dependency layers. Copy pyproject.toml and uv.lock first, run uv sync --locked --no-install-project, and then copy the rest of your source code. This allows Docker to cache your dependencies so code edits don't trigger a full reinstall. • Exclude development tools. Pass --no-dev (or set ENV UV_NO_DEV=1) to keep testing and linting packages out of your production image. • Ignore local environments. Add .venv to your .dockerignore file so your host machine's virtual environment isn't accidentally copied into the container. Minimal Dockerfile Example: Following the Astral uv Docker Guide, a standard setup looks like this: FROM python:3.12-slim COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ WORKDIR /app # Install dependencies first for Docker layer caching RUN --mount=type=cache,target=/root/.cache/uv \ --mount=type=bind,source=uv.lock,target=uv.lock \ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ uv sync --locked --no-install-project --no-dev # Copy application code and install the project itself COPY . /app RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --locked --no-dev # Run the application using the virtual environment ENV PATH="/app/.venv/bin:$PATH" CMD ["python", "main.py"] When You Might Skip uv.lock • Publishing a reusable library: If your container is meant to test a library against the latest upstream dependencies rather than deploy a fixed application, you would resolve directly from pyproject.toml without a lockfile. • Legacy requirements.txt workflows: If your deployment pipeline strictly requires standard pip tooling without uv inside the container, you can export your lockfile first (uv export --format requirements-txt > requirements.txt) and install from that instead.