Skip to Content
CLI Referencenkapp clean

nkapp clean

clean [-e <env>] [-y]

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/.
nkapp clean [options]

Options

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

What Gets Removed

ResourceRemoved?Target
Service containersLocal & Cloud
Gateway / Load BalancerLocal & Cloud (ALB/NLB)
Named volumes (caches, DBs)Local & Cloud (EFS)
Docker networks / VPCLocal & Cloud
Nanokit state filesLocal
Target GroupsCloud
CloudWatch Log GroupsCloud
Elastic IPsCloud

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 now 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 destroy

CommandContainersVolumesState
nkapp destroy✅ Removed❌ Kept❌ Kept
nkapp clean✅ Removed✅ Removed✅ Removed

Examples

# Full wipe of local environment nkapp clean -e local -y # Clean staging (with confirmation prompt) nkapp clean -e stage

[!CAUTION] This operation is irreversible. All persistent data in named volumes (databases, caches, node_modules) will be permanently deleted. Run nkapp up afterwards to reconcile from scratch.