skillfed

python-on-whales

A Docker client for Python, designed to be fun and intuitive!

python-on-whales v0.81.0 12.8M downloads/30d#1,303 on PyPI709
Permissive license MIT License Copyright (c) 2020 Gabriel de Marmiesse de Lussan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) Active released

What it is and what it does

python-on-whales is a Python wrapper around the Docker CLI that translates Docker commands into intuitive Python method calls. Instead of shelling out to docker run or docker build, you call methods directly from Python code like run(), build(), pull(), and compose operations. It handles container lifecycle management, image operations, volume creation, networking, and Docker Compose orchestration.

The package is designed as a thin, direct mapping of Docker CLI operations to Python, so developers familiar with Docker commands can immediately recognize the equivalent Python calls. It depends on pydantic and typing-extensions for data validation and type hints, and requires Docker or Podman to be installed separately on the host system. The API returns Python objects that can be used as context managers to ensure cleanup, making it suitable for automation scripts, testing frameworks, and CI/CD pipelines.

Use it for:

  • Automate container lifecycle in Python test suites by spinning up, configuring, and tearing down containers programmatically.
  • Build and push Docker images from Python scripts without subprocess calls or shell escaping.
  • Orchestrate multi-container applications using Docker Compose from Python code.
  • Copy files between host and containers, manage volumes, and inspect running containers in deployment automation.
  • Integrate GPU-enabled containers into Python applications with native parameter passing.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A Python Docker client that wraps the Docker CLI with an intuitive, Pythonic API for container, image, and compose operations on Linux, macOS, and Windows.

Yes. The package has low install friction, active maintenance, no known vulnerabilities, and a permissive MIT License. It solves a real problem—making Docker operations accessible and type-safe from Python—and is well-positioned for automation, testing, and CI/CD use cases. Install it if you need to orchestrate Docker from Python code.

Install

python-on-whales on PyPI

pip

pip install python-on-whales

uv

uv add python-on-whales

poetry

poetry add python-on-whales

Installing python-on-whales

Before you install

Low install friction with only two lightweight runtime dependencies (pydantic and typing-extensions). Active maintenance with recent commits and steady releases since 2020.

License in practice

MIT License permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.

Quickstart

pip install python-on-whales

from python_on_whales import docker

output = docker.run("hello-world")
print(output)

Requires Docker or Podman to be installed and running on the system; Python 3.8 or above.

Verify before relying

  • Whether the package supports Podman as a full alternative to Docker or only partial compatibility.
  • Performance characteristics when managing large numbers of containers or images.
  • Full scope of Docker Compose features supported through the python-on-whales API.

Package facts

License MIT License Copyright (c) 2020 Gabriel de Marmiesse de Lussan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive)
Python support supports the current Python release (<4,>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pydantic, typing-extensions
Maintenance actively maintained — 158 days since the last release
Last repo commit
First released
Downloads 12,831,777/month — #1,303 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_on_whales-0.81.0-py3-none-any.whl

Tags

docker client pythonpython docker api wrapperdocker container management pythondocker compose automationpythonic docker clidocker build run pull pythoncontainer orchestration python
docker-automationcontainer-orchestrationdevops-tooling

More Build Tools packages