Skip to content

nkapp clean ​

Hard Reset (Nuclear Option): Wipes ALL containers, volumes, networks, and state for the project.

  • Local: Removes all Docker resources and wipes local state files.
  • Cloud (AWS/GCP): Performs a deep infrastructure wipe, including Load Balancers, Target Groups, Log Groups, and VPC networking to prevent orphaned resources.
  • More destructive than destroy — also removes persistent data (volumes), cloud-native gateways, and local state files.
  • Remote Integration: Automatically triggers infra destroy on the active provider to ensure no orphaned resources or costs remain on cloud platforms (AWS, DigitalOcean, etc.).
  • Local Integration: Wipes all local metadata and caches in .nanokit/.
bash
nkapp clean [options]

Options ​

FlagTypeDefaultDescription
-e, --env <env>stringlocalTarget environment
-y, --yesbooleanfalseSkip confirmation prompt

What Gets Removed ​

ResourceRemoved?Target
Service containers✅Local & Cloud
Gateway / Load Balancer✅Local & Cloud (ALB/NLB)
Named volumes (caches, DBs)✅Local & Cloud (EFS)
Docker networks / VPC✅Local & Cloud
Nanokit state files✅Local
Target Groups✅Cloud
CloudWatch Log Groups✅Cloud
Elastic IPs✅Cloud

Nuclear Clean on Cloud Providers ​

When running nkapp clean on cloud providers (like AWS), Nanokit performs a "Nuclear" deep clean. It doesn't just stop services; it actively discovers and destroys all project-tagged infrastructure to prevent orphaned resources and hidden costs.

This includes:

  • Releasing unassociated Elastic IPs.
  • Deleting Application/Network Load Balancers.
  • Wiping EFS File Systems.
  • Detaching and deleting Internet Gateways and Subnets.
  • Waiting for ENIs (Network Interfaces) to settle before final VPC removal.

By default the AWS deep clean sweeps only the environment's configured region (resolved from the env's deploy target, or the provider default) instead of all ~17 regions — faster and sufficient, since resources only live in that region. When the region cannot be resolved (e.g. an ephemeral CI runner with no nanokit.yml), Nanokit falls back to the full multi-region sweep automatically. For an explicit single-region or full-sweep teardown from CI, use nkapp teardown with --region / --all-regions.


Difference from the other teardown commands ​

CommandContainersVolumesLocal stateScope
nkapp destroy✅ Removed❌ Kept (-v to remove)❌ KeptThis project + env
nkapp clean✅ Removed✅ Removed✅ RemovedThis project + env
nkapp teardown✅ Removed✅ Removed✅ RemovedTag-based, state-free (for CI)
nkapp volumes prune—Orphans only❌ KeptOrphaned volumes only

Examples ​

bash
# Full wipe of local environment
nkapp clean -e local -y

# Clean staging (with confirmation prompt)
nkapp clean -e stage

DANGER

This operation is irreversible. All persistent data in named volumes (databases, caches, node_modules) is permanently deleted.

To rebuild afterwards: nkapp up -e local for a local environment, but nkapp deploy -e <env> for a remote or cloud one — since the up/deploy split, up no longer provisions infrastructure, and a just-cleaned remote environment has none.