Skip to content

[FEATURE] delete command #71

@CarloQuick

Description

@CarloQuick

Feature Summary

Add a delete command that removes a container's filesystem and manifest entry — the inverse of create. Supports a --force flag to kill running containers before deletion.

cargo run -- delete busybox-container
cargo run -- delete busybox-container --force

Problem/Use Case

There's no way to clean up containers after they're created and stopped. Users have to manually delete directories and edit container_manifest.json. Every container runtime needs a way to remove containers.

Proposed Solution

delete removes the container directory under {BENTO_CONTAINERS_PATH}/{name}/ and its entry in container_manifest.json.

Default behavior:

  • Deletes containers in Created or Stopped state
  • Refuses to delete Running containers

With --force:

  • Kills running containers first (SIGKILL), then deletes

Container not found → bail, same as other commands.

Does NOT touch the image directory — images are shared across containers.

Acceptance Criteria

  • Feature is implemented and working
  • Tests are written and passing
  • Documentation is updated
  • Performance impact is acceptable

Priority

Medium

Implementation Details

Files to touch: bento_cli.rs, main.rs, runtime.rs

Things to be aware of:

  • rollback_container_manifest() and rollback_dirs() already exist and do most of the heavy lifting
  • After --force killing a running container, there's a race with the parent process in fork_into_namespaces doing its waitpid → status update → unmount_and_clean_up. Look at how stop handles this timing (the sleep + poll pattern around line 527-549 of runtime.rs)
  • Handle the case where the container directory is already gone (someone manually deleted it) — still clean the manifest
  • Handle the case where manifest says Running but pid is None--force should still clean up even if kill_container() fails

UX messages:

  • 🍱 Container {name} deleted
  • 🍱 Container {name} killed and deleted
  • Container '{name}' is currently running. Use --force to kill and delete it.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions