Metadata-Version: 2.4
Name: container-detect
Version: 1.0.0
Summary: Detect if your Python process is running inside a container. Supports Docker, Podman, Kubernetes, containerd, LXC, and more. Inspired by the popular is-inside-container npm package. Supports cached results with optional refresh.
Project-URL: Homepage, https://github.com/ysskrishna/container-detect
Project-URL: Repository, https://github.com/ysskrishna/container-detect.git
Project-URL: Issues, https://github.com/ysskrishna/container-detect/issues
Project-URL: Changelog, https://github.com/ysskrishna/container-detect/blob/main/CHANGELOG.md
Project-URL: Discussions, https://github.com/ysskrishna/container-detect/discussions
Author-email: "Y. Siva Sai Krishna" <sivasaikrishnassk@gmail.com>
License: MIT
License-File: LICENSE
Keywords: container,container-detection,containerd,containerized,detect,detection,docker,environment,inside,is-inside-container,kubernetes,lxc,mit license,podman,process,utilities,utils,ysskrishna
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# Container Detect

[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ysskrishna/container-detect/blob/main/LICENSE)
![Tests](https://github.com/ysskrishna/container-detect/actions/workflows/test.yml/badge.svg)
[![PyPI](https://img.shields.io/pypi/v/container-detect)](https://pypi.org/project/container-detect/)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/container-detect?period=total&units=INTERNATIONAL_SYSTEM&left_color=GREY&right_color=BLUE&left_text=downloads)](https://pepy.tech/projects/container-detect)

Detect if your Python process is running inside a container. Supports Docker, Podman, Kubernetes, containerd, LXC, and more. Inspired by the popular [is-inside-container](https://github.com/sindresorhus/is-inside-container) npm package. Supports cached results with optional refresh.

## Features

- Fast and reliable container detection for multiple container types
- Supports Docker, Podman, Kubernetes, containerd, LXC, and more
- Multiple detection methods for robustness
- Cached results for performance optimization
- Zero dependencies, minimal overhead
- Type hints for better IDE support
- Graceful error handling

## Supported Container Types

- **Docker** - Classic Docker containers
- **Podman** - Podman containers
- **Kubernetes** - Kubernetes pods
- **containerd** - containerd containers
- **LXC** - Linux Containers
- **CRI-O** - Container Runtime Interface
- **AWS ECS** - Amazon Elastic Container Service
- And more container runtimes

## Installation

```bash
pip install container-detect
```

Or using `uv`:

```bash
uv add container-detect
```

## Usage

### Check if running inside a container

```python
from container_detect import is_inside_container

if is_inside_container():
    print("Running inside a container")
else:
    print("Not running inside a container")
```

### Force refresh cache

```python
from container_detect import is_inside_container

# Use cached result (default)
is_inside_container()  # Fast, uses cache

# Force a fresh check, bypassing cache
is_inside_container(force_refresh=True)  # Performs new detection
```



## Credits

This package is inspired by the [is-inside-container](https://github.com/sindresorhus/is-inside-container) ([npm](https://www.npmjs.com/package/is-inside-container)) npm package by [Sindre Sorhus](https://github.com/sindresorhus).

## Changelog

See [CHANGELOG.md](https://github.com/ysskrishna/container-detect/blob/main/CHANGELOG.md) for a detailed list of changes and version history.

## Contributing

Contributions are welcome! Please read our [Contributing Guide](https://github.com/ysskrishna/container-detect/blob/main/CONTRIBUTING.md) 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](https://github.com/sponsors/ysskrishna) | [Support on Patreon](https://patreon.com/ysskrishna)

## License

MIT License - see [LICENSE](https://github.com/ysskrishna/container-detect/blob/main/LICENSE) file for details.

## Author

**Y. Siva Sai Krishna**

- GitHub: [@ysskrishna](https://github.com/ysskrishna)
- LinkedIn: [ysskrishna](https://linkedin.com/in/ysskrishna)
