Docker Detector
Detect if your Python process is running inside a Docker container. Inspired by the popular is-docker npm package. Supports cached results with optional refresh.
Features
- Fast and reliable Docker container detection
- Multiple detection methods for robustness
- Cached results for performance optimization
- Zero dependencies, minimal overhead
- Type hints for better IDE support
Installation
pip install docker-detector
Or using uv:
uv add docker-detector
Usage
Check if running inside Docker
from docker_detector import is_docker
if is_docker():
print("Running inside a Docker container")
else:
print("Not running inside a Docker container")
Force refresh cache
from docker_detector import is_docker
# Use cached result (default)
is_docker() # Fast, uses cache
# Force a fresh check, bypassing cache
is_docker(force_refresh=True) # Performs new detection
Credits
This package is inspired by the is-docker npm package by Sindre Sorhus.
Changelog
See CHANGELOG.md for a detailed list of changes and version history.
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, development setup, and the process for submitting pull requests.
Support
If you find this library useful, please consider:
- ⭐ Starring the repository on GitHub to help others discover it.
- 💖 Sponsoring to support ongoing maintenance and development.
Become a Sponsor on GitHub | Support on Patreon
License
MIT License - see LICENSE file for details.
Author
Y. Siva Sai Krishna
- GitHub: @ysskrishna
- LinkedIn: ysskrishna
Metadata
Release files for docker-detector 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| docker_detector-1.0.1.tar.gz | 15.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docker_detector-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.2 kB
Release files / docker_detector-1.0.1.tar.gz
| Download URL | docker_detector-1.0.1.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
087136388e0e533a40897212df49d39c5acdecfcbe6bd95e736a08369373c0d9
|
|
BLAKE2b-256 checksum How to use checksums |
972c636fdba56f7047ece3efd184bb987e85ffedd515d6539d88882bd19835c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / docker_detector-1.0.1-py3-none-any.whl
| Download URL | docker_detector-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b4cf0835aaf65f3df3df6f3435afbe289a2f80063aef2de9f3152dd7bbf66cc
|
|
BLAKE2b-256 checksum How to use checksums |
73c1b3e32ef116a4b0fbb93eb14d19a1a9767467506e75fc154174e3959aa95d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|