Skip to content

nkapp destroy ​

Stop and remove services and infrastructure. Also aliased as nkapp down.

bash
nkapp destroy [services...] [options]
nkapp down [services...]   # alias

Arguments ​

ArgumentTypeDescription
servicesstring[]Optional list of service names. If omitted, destroys everything.

Options ​

FlagTypeDefaultDescription
-e, --env <env>stringlocalTarget environment
-v, --volumesbooleanfalseRemove associated persistent volumes
--ssh <host>string—Target an explicit host (e.g. root@1.2.3.4), overriding the environment's configured deploy target
-p, --port <port>number22SSH port (used with --ssh)
-i, --ssh-key <path>string—SSH private key override (used with --ssh)
-y, --yesbooleanfalseSkip confirmation prompt

Behavior ​

Selective Destruction ​

When service names are provided, only those containers are stopped and removed. Infrastructure and other services remain untouched.

bash
nkapp destroy api worker

Untracked resources matching the name are auto-discovered, so a container that drifted out of the local state file is still removed.

Full Destruction ​

When no service names are provided, all services and project-level infrastructure are destroyed:

  • All service containers are removed
  • The project network is removed
  • The gateway and bridge containers are removed
  • Infrastructure resources (cloud instances) are destroyed

Cross-project safety ​

Teardown is scoped by the nk-project + nk-env labels. A container belonging to another project or another environment is never removed, even if its name looks similar.


Host override (--ssh) ​

Point the teardown at an explicit host instead of the environment's configured target (and instead of the local → local-Docker default). This is how you clean up stranded or cross-host resources, e.g. after a nkapp migrate left the old host behind:

bash
nkapp destroy --ssh root@1.2.3.4 -i ~/.ssh/id_rsa -e stage -y

The same override exists on volumes prune, containers prune and images prune.


Remote Support ​

For remote environments (without --ssh), Nanokit establishes an SSH tunnel before issuing destroy commands. The tunnel is cleaned up automatically after completion.


Examples ​

bash
# Destroy everything in local
nkapp destroy -y

# Destroy specific services
nkapp destroy api -e stage

# Full teardown of staging
nkapp down -e stage -y

# Teardown including data volumes (DANGEROUS)
nkapp destroy -e stage -v -y

DANGER

Full destruction removes all containers and associated state. Persistent volumes are not removed by default — use -v / --volumes to explicitly remove them (e.g. database data). Use nkapp clean for a total project wipe, or nkapp teardown for a state-free, tag-based sweep in CI.