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 the target containers themselves.
Goal
The end goal is a full-featured chaos engineering platform for Docker networks. It will allow users to define fault scenarios (e.g., "break OSPF adjacency," "add 200ms latency + 10% packet loss on an uplink") and run them on demand against containerized infrastructure. An observability stack will monitor and record how the network recovers.
What Has Been Done So Far
Phase 1: Core PoC
A fully functional Proof of Concept that proves we can manipulate the Linux kernel network parameters of any Docker container to simulate disasters.
- One-shot privileged sidecar (
chaos-sidecar): Enters the target container's network namespace usingnsenterto runtccommands directly. - Effect stacking: Latency and packet loss can be combined into a single composite
tcrule. - Idempotent recovery:
--action clearremoves alltcrules and restores normal network behavior. - Zero victim requirements: Target containers need no extra capabilities, no
iproute2, and no pre-configuration.
Phase 2: Distribution
The tool is now pip-installable and published to PyPI. The sidecar image is resolved automatically:
- Check local Docker cache for the pinned version.
- If missing, try pulling
rickysf/chaos-sidecar:<version>from Docker Hub. - If the registry is unreachable, fall back to building the sidecar from the bundled
Dockerfile.
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. |
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 the victim test container
docker build -t chaos-victim tests/victim
docker run -d --name victim chaos-victim
2. Verify baseline connectivity
docker exec victim ping -c 4 8.8.8.8
3. Inject chaos via chaosctl
# Add 500ms latency
chaosctl --target victim --action latency --value 500
# Verify the effect
docker exec victim ping -c 4 8.8.8.8
# Stack 20% packet loss on top
chaosctl --target victim --action loss --value 20
# Verify both effects
docker exec victim ping -c 20 8.8.8.8
# Recover
chaosctl --target victim --action clear
# Verify recovery
docker exec victim ping -c 4 8.8.8.8
4. 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
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 logic)
│ ├── docker_client.py # Resolves container name -> PID
│ ├── network_chaos.py # tc command builder with stacking
│ └── sidecar_runner.py # Host wrapper (chaosctl entrypoint)
└── tests/
└── victim/
└── Dockerfile # Minimal Alpine victim for testing
Next Steps (Phase 3)
- Scenario definitions via YAML config files.
- Timed chaos (auto-clear after N seconds).
- Support for additional fault types: jitter, corruption, bandwidth throttling, network partitions.
- Observability hooks (Prometheus metrics, Grafana dashboard).
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.2.0.tar.gz.
File metadata
- Download URL: network_chaos_tool-0.2.0.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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 |
c5d2d81d78c9c4f855f5d21bad4514e9a1d0710756c22b331e6329bf617f85ef
|
|
| MD5 |
b2e2504cf63cb690e7e04be8ed123306
|
|
| BLAKE2b-256 |
a3e4bdceaaeddab3e259ca662fe698d08ccca411545d45962e9a79655e4bf1d2
|
File details
Details for the file network_chaos_tool-0.2.0-py3-none-any.whl.
File metadata
- Download URL: network_chaos_tool-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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 |
99cb7957956e660deeaf77a94cd44c2a6d33d7e8f0ca58fbc1ad34c6c056138c
|
|
| MD5 |
648122e7c02290344b42b20d8c1838e5
|
|
| BLAKE2b-256 |
9a8a15032c5637b0dc85202facd534f7f89ef2917a43aa22d430a00a33f40a1f
|