π runit
Run Python scripts instantly in containers - no setup, no fuss, just run it.

β¨ Features
- π Zero Python Setup - No local Python installation needed
- π Isolated Environment - Each script runs in its own container
- π¦ Auto Dependencies - Automatically detects and installs required packages
- π― Simple Interface - Single command to run any Python script
- π Port Forwarding - Easy exposure of network services
- π¨ Version Flexible - Use any Python version you need
π Quick Start
Requirements
- Docker: Container runtime (version 20.10 or higher recommended)
- Go: Required for installation from source (version 1.19 or higher)
- Internet connection: For pulling Docker images and installing dependencies
Installation
go install github.com/kanthorlabs/runit/cmd/runit@latest
Basic Usage
# Run a simple script
runit script.py
# Run with specific Python version
runit --platform-version python:3.11-slim script.py
# Expose ports
runit --ports 8080 webapp.py
# Pass arguments to your script
runit github-analyzer.py --arguments="kanthorlabs/runit"
π― Command Reference
Syntax
runit [flags] <script>
Flags
| Flag |
Description |
Default |
--platform-version |
Python Docker image version |
python:3.13-slim |
--ports |
Expose ports (repeatable) |
- |
--arguments |
Script arguments |
- |
--params |
Script parameters |
- |
π Advanced Examples
Note: You can find the source code for these examples in the examples/python directory.
# Web application with multiple ports
runit webapp.py --ports 8080 --ports 9090
# GitHub analyzer with authentication
runit examples/python/github-analyzer.py \
--arguments="kanthorlabs/runit" \
--params="--token=xxx"
# Machine learning script with specific Python version
runit examples/python/analyze-image.py \
--platform-version python:3.11-slim \
--arguments="https://i.ibb.co/KxcPH8LF/Screenshot-2025-03-11-at-11-09-33.png" \
--params="--api-key=sk-proj-xxx"
ποΈ Architecture
flowchart TD;
User -- "runit script.py [flags]" --> CLI[runit CLI]
subgraph AP [Analysis & Packaging]
direction TB
CLI -->|Reads| Script[Script File]
Script -->|Analyzes Dependencies| Lockfile(requirements.txt)
CLI -->|Generates| Dockerfile(Dockerfile)
Script & Lockfile & Dockerfile --> Ctx[Build Context]
end
subgraph DO [Docker Operations]
direction TB
Ctx -->|Builds Image| Image[Docker Image]
Image -->|Runs Container| Container[Docker Container]
Container -->|Streams Logs| Output[STDOUT/STDERR]
Container -->|Cleanup| Removed[Container Removed]
end
AP --> DO
DO --> Output
π§© How It Works
- Analysis: Scans your Python script for dependencies
- Packaging: Creates a container with your script and dependencies
- Execution: Runs the script in an isolated environment
- Cleanup: Automatically removes the container after execution
π‘ Pro Tips
- Use
python:*-slim images for faster downloads
- Leverage port forwarding for web applications
- Include requirements.txt for explicit dependencies
- Use environment variables for sensitive data
π€ Contributing
We welcome contributions! Here's how you can help:
- π Report bugs
- π‘ Suggest features
- π§ Submit pull requests
- π Improve documentation
π License
MIT License - View License