Programmable chaos engineering tool for Docker-based network topologies
Project description
Network Chaos Tool
A programmable chaos engineering tool that targets Docker-based network topologies. It injects network faults - latency, packet loss, and more - into running containers at runtime using tc (traffic control) via a privileged sidecar, without requiring any special capabilities inside t0he target containers themselves.
Goal
The goal is a full-featured0 chaos engineering platform for Docker networks. It allows users to define fault scenarios and run them on demand against containerized infrastructure, with live observability for how the network responds.
Features
- Privileged sidecar (
chaos-sidecar): Enters the target container's network namespace usingnsenterto runtccommands directly. - Composite faults: Latency and packet loss can be combined into a single
tcrule. - Auto-clear: Optional duration-based cleanup via
--duration. - Scenario runner: Run YAML-defined scenarios with
chaosctl run. - Live dashboard: Web UI with live tc metrics and ping measurements via
chaosctl serve. - Zero victim requirements: Target containers need no extra capabilities, no
iproute2, and no pre-configuration. - Sidecar image resolution: Uses local cache, then Docker Hub, then bundled
Dockerfilefallback.
Supported Faults
| Action | Description |
|---|---|
latency |
Add a fixed delay (ms) to all outgoing traffic. |
loss |
Add a random packet loss (%) to all outgoing traffic. |
clear |
Remove all tc rules and restore normal network behavior. |
| 0 |
Prerequisites
- Docker Engine running locally.
- Python 3.10+.
- A Linux host (or VM) where
nsenterandtcare available.
Installation
pip install network-chaos-tool
For development, you can also install from source with uv:
uv pip install -e .
Quick Start
1. Build a victim container
docker build -t chaos-victim tests/victim
docker run -d --name victim chaos-victim
2. Inject chaos via chaosctl
# Add 500ms latency
chaosctl --target victim --action latency --value 500
# Stack 20% packet loss on top (composite mode)
chaosctl --target victim --latency 500 --loss 20
# Auto-clear after 5 seconds
chaosctl --target victim --action loss --value 20 --duration 5000
# Recover
chaosctl --target victim --action clear
3. Start the live dashboard
chaosctl serve --port 8080
Open http://localhost:8080. The server auto-starts a chaos-monitor sidecar for live metrics.
4. Run a scenario YAML
chaosctl run examples/full-test.yaml
# Validate only
chaosctl run examples/full-test.yaml --dry-run
5. Advanced options
# Use a specific sidecar image version
chaosctl --target victim --action clear --sidecar-version 0.2.0
# Force a local build from bundled source (offline mode)
chaosctl --target victim --action clear --local-build
# Manually start a persistent monitor sidecar
chaosctl monitor --monitor-host-port 9090
CLI Reference
chaosctl (host-side wrapper)
# Inject faults
chaosctl --target <container> --action latency --value <ms>
chaosctl --target <container> --action loss --value <percent>
chaosctl --target <container> --action clear
# Composite faults
chaosctl --target <container> --latency <ms> --loss <percent>
# Auto-clear after N ms
chaosctl --target <container> --action loss --value 20 --duration 5000
# Serve dashboard
chaosctl serve --host 0.0.0.0 --port 8080
# Run scenario YAML
chaosctl run path/to/scenario.yaml --dry-run
# Start monitor sidecar (optional; dashboard auto-starts it)
chaosctl monitor --monitor-host-port 9090
chaos (sidecar-only)
chaos runs inside the privileged sidecar container and is not meant to be invoked directly on the host.
Project Structure
proj/
├── pyproject.toml # Project config (hatchling)
├── uv.lock # Locked dependency tree
├── Dockerfile # Sidecar image definition
├── LICENSE # MIT License
├── README.md # This file
├── injector/ # Core chaos logic
│ ├── __init__.py # Package metadata
│ ├── __main__.py # Entry point for `python -m injector`
│ ├── cli.py # Runs inside sidecar (nsenter + monitor)
│ ├── docker_client.py # Resolves container name -> PID
│ ├── monitor.py # Monitor FastAPI app (metrics + ping)
│ ├── network_chaos.py # tc command builder with stacking
│ ├── scenario_executor.py # YAML scenario runner
│ ├── sidecar_runner.py # Host wrapper (chaosctl entrypoint)
│ ├── templates/ # Dashboard HTML templates
│ └── web_server.py # Dashboard FastAPI app
├── examples/ # Scenario YAML examples
└── tests/
└── victim/
└── Dockerfile # Minimal Alpine victim for testing
Roadmap
- Support for additional fault types: jitter, corruption, bandwidth throttling, network partitions.
- Export metrics to external observability stacks (Prometheus/Grafana).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file network_chaos_tool-0.4.0.tar.gz.
File metadata
- Download URL: network_chaos_tool-0.4.0.tar.gz
- Upload date:
- Size: 95.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d8a02b672fa31c72ef4dc928d60f626b0d9846811da8380b92946a726aa264e
|
|
| MD5 |
afafd6237df696d44ba8864af7f8fac3
|
|
| BLAKE2b-256 |
0c7840a55cd8bda2223cbe2dab4c8fb6eb24de5b75923b006ba9c4ba50b132fc
|
File details
Details for the file network_chaos_tool-0.4.0-py3-none-any.whl.
File metadata
- Download URL: network_chaos_tool-0.4.0-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a8a9c5da62368c6966c40ae8696d20f70b5a810e1dd70aef6fc291d25cc84d8
|
|
| MD5 |
73dcbe5e2923cef0648d5bbb4a7b2732
|
|
| BLAKE2b-256 |
b1addf64b051dce07bb93bf09aa83acf2b3a282932f2bb1bea289f7221a9c1f4
|