dockerpty
Python library to use the pseudo-tty of a docker container
What it is and what it does
dockerpty is a Python library that bridges the gap between a host terminal and a Docker container's pseudo-terminal (PTY), allowing you to run interactive shell sessions inside containers as if you were directly connected to them. It handles the low-level details of terminal control: piping stdin/stdout/stderr between host and container, managing raw terminal mode, handling window resize signals, and restoring terminal state on exit.
The library is designed for scenarios where you need programmatic, interactive access to a container's shell from Python. It also supports non-TTY attachment for streaming container output. However, the project is abandoned (last release 2016-02-04, no commits since 2019-10-16) and does not explicitly declare its runtime dependency, creating friction for new installations and raising questions about compatibility with modern tooling.
Use it for:
- Run interactive shell sessions inside Docker containers from Python scripts, giving users direct terminal control.
- Implement programmatic container debugging or administration tools that need real-time terminal interaction.
- Stream container output in non-TTY mode when interactive control is not required.
- Detach from and re-attach to running containers without stopping them.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Operates the pseudo-terminal (PTY) allocated to a Docker container, enabling interactive terminal control of containerized processes from Python.
No. The package is abandoned (last release 2016-02-04, no commits since 2019-10-16) and does not explicitly declare its runtime dependency, creating installation friction and compatibility risk. Modern Docker tooling has evolved significantly since then. Consider using maintained alternatives or the official Docker SDK for interactive container control.
Install
dockerpty on PyPI
pip
pip install dockerptyuv
uv add dockerptypoetry
poetry add dockerptyInstalling dockerpty
Before you install
High install friction: the package does not explicitly declare its runtime dependency in PyPI, requiring manual installation. Maintenance is abandoned—last release was 2016-02-04, with no commits since 2019-10-16.
License in practice
Licensed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions, though you should review the LICENSE.txt file for exact terms.
Quickstart
pip install dockerpty
import dockerpty
dockerpty.start(client, container)
Requires an undeclared external dependency (docker-py >=0.3.2); only works when run in an actual terminal; requires Docker daemon running locally.
Verify before relying
- Compatibility with modern Docker SDK versions—last release predates major Docker API changes.
- Python version support—requires_python is unspecified; may not work on modern Python versions.
- Whether the undeclared dependency is still the correct package name or has been superseded.
- Current usability with contemporary Docker tooling and container runtimes.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,844 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 706,753/month — #5,271 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dockerpty-0.4.1.tar.gz
Keywords: docker, tty, pty, terminal
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
ptyprocessRun a subprocess in a pseudo terminal (pty) and…
permissive · top 1,000 on PyPI
pywinptyPyWinpty creates and manages pseudoterminals on…
permissive · top 5,000 on PyPI
pairmuxpairmux lets AI agents control interactive…
permissive · top 15,000 on PyPI
jupyter-server-terminalsAdds terminal support to Jupyter Server,…
permissive · top 1,000 on PyPI
dockerA Python library that lets you programmatically…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
docker-pyA Python client library that lets you control…
permissive · top 5,000 on PyPI
subprocess-multiteeMultiplexes subprocess stdout/stderr to…
unclear · top 15,000 on PyPI
bashProvides a Python wrapper for running bash…
copyleft · top 15,000 on PyPI
spurProvides a unified Python interface to run…
permissive · top 15,000 on PyPI