Skip to main content
Containerizing Pixi packages is an effective way to bring them into production environments using Docker or Podman.

Pixi Docker Images

The official pixi-docker repository provides Docker images with Pixi pre-installed on various base images.

Available Images

Images are available at ghcr.io/prefix-dev/pixi:
  • latest - Ubuntu Jammy (22.04)
  • focal - Ubuntu Focal (20.04)
  • bullseye - Debian Bullseye
  • noble-cuda-12.9.1 - Ubuntu 24.04 with CUDA 12.9.1
  • noble-cuda-13.0.0 - Ubuntu 24.04 with CUDA 13.0.0
  • …and more
For all available tags, see the build script.

Best Practices Blog Post

Learn best practices for shipping conda environments to production using Pixi and Docker

Multi-Stage Dockerfile Example

This example demonstrates a production-ready multi-stage build that uses pixi shell-hook to avoid including Pixi in the final image:
Dockerfile
For more examples, see pavelzw/pixi-docker-example.

Advanced Docker Setup

This example demonstrates using solve-groups and per-environment editability for optimal development and production workflows.

Project Structure

pyproject.toml

Multi-Stage Production Dockerfile

Dockerfile

Docker Compose for Development

docker-compose.yml

Usage Commands

1

Development with Docker Compose

This runs the development server with hot-reload enabled via the mounted volume.
2

Production Build and Run

This creates an optimized production image without Pixi or development dependencies.

Key Concepts

Shell Hook

The pixi shell-hook command generates shell code to activate the environment without requiring Pixi:
Output:

Solve Groups

Solve groups ensure that different environments (dev/prod) use identical dependency versions:
This guarantees consistency between development and production.

Environment Editability

  • Development: Use editable = true for fast iteration without rebuilds
  • Production: Use editable = false for a clean, optimized installation

Best Practices

Multi-Stage Builds

Use multi-stage builds to minimize final image size by excluding build tools and Pixi itself.

Lock Files

Always use --locked flag to ensure reproducible builds with exact dependency versions.

Layer Caching

Copy pixi.toml and pixi.lock before source code to leverage Docker’s layer caching.

Path Consistency

Keep the environment path identical between build and runtime stages for proper activation.

Minimal Base Images

Use minimal base images like Ubuntu or Debian for smaller final image sizes.

Troubleshooting

Environment Not Activating

Ensure the prefix path remains the same between build and runtime:

Missing Dependencies

Verify all runtime dependencies are in the production environment, not just development:

Large Image Size

Use multi-stage builds and avoid including:
  • Pixi binary in final image
  • Development dependencies
  • Build tools and compilers
  • Source code if only wheels are needed