Detect container runtimes, not only Docker, from your Python process
When it’s useful
The same service might run under Docker, Podman, Kubernetes, containerd, or another OCI-style environment. If you only check for Docker, you misclassify everything else. This library aims for broad container detection behind one entry point, with optional cache refresh when you cannot afford stale answers.
What you can do
- Call
is_inside_container()to branch logging, paths, or behavior when the process appears to be inside a supported container style. - Cover the runtimes called out in the project docs, including Docker, Podman, Kubernetes, containerd, LXC, CRI-O, AWS ECS, and related paths the implementation tests against.
- Benefit from multiple detection strategies and graceful error handling so a failed probe does not take down your app.
- Cache by default and bypass the cache when you need a fresh read after environment changes.
Limits and fit
Like any environment probe, results depend on what the host exposes; new runtimes or hardened images may need updates upstream. It tells you “inside a container per heuristics,” not “which cloud account” or “which orchestrator version.” Python 3.8+; install from PyPI (container-detect). Details match the GitHub repository, inspired by the is-inside-container npm package.



