mirror of
https://github.com/apple/container.git
synced 2026-11-10 16:09:11 +00:00
add volume prune command (#783)
- Closes #508. ## Type of Change - [ ] Bug fix - [x] New feature - [ ] Breaking change - [ ] Documentation update ## Motivation and Context Adds a `container volume prune` command that removes volumes with no container references and reports the amount of disk space reclaimed. This helps users clean up unused volumes and easily reclaim disk space. Also updates the `volume delete` documentation to clarify and highlight how the `--all` flag works. ## Testing - [x] Tested locally - [x] Added/updated tests - [x] Added/updated docs
This commit is contained in:
9 files changed
+332
-4
No files matched your search
@@ -617,15 +617,66 @@ container volume rm $VOL
|
||||
|
||||
### `container volume delete (rm)`
|
||||
|
||||
Removes one or more volumes by name.
|
||||
Removes one or more volumes by name. Volumes that are currently in use by containers (running or stopped) cannot be deleted.
|
||||
|
||||
**Usage**
|
||||
|
||||
```bash
|
||||
container volume delete NAME...
|
||||
container volume delete [OPTIONS] [NAME...]
|
||||
```
|
||||
|
||||
Only global flags are available.
|
||||
**Arguments**
|
||||
|
||||
* `NAME...`: Volume names to delete
|
||||
|
||||
**Options**
|
||||
|
||||
* `-a, --all`: Delete all volumes (only removes volumes not in use)
|
||||
* **Global**: `--debug`, `--version`, `-h`/`--help`
|
||||
|
||||
**Examples**
|
||||
|
||||
```bash
|
||||
# delete a specific volume
|
||||
container volume delete myvolume
|
||||
|
||||
# delete multiple volumes
|
||||
container volume delete vol1 vol2 vol3
|
||||
|
||||
# delete all unused volumes
|
||||
container volume delete --all
|
||||
```
|
||||
|
||||
### `container volume prune`
|
||||
|
||||
Removes all volumes that have no container references. This includes volumes that are not attached to any running or stopped containers. The command reports the actual disk space reclaimed after deletion.
|
||||
|
||||
**Usage**
|
||||
|
||||
```bash
|
||||
container volume prune [OPTIONS]
|
||||
```
|
||||
|
||||
**Options**
|
||||
|
||||
* **Global**: `--debug`, `--version`, `-h`/`--help`
|
||||
|
||||
**Examples**
|
||||
|
||||
```bash
|
||||
# remove all unused volumes
|
||||
container volume prune
|
||||
```
|
||||
|
||||
**Example output:**
|
||||
|
||||
```
|
||||
Pruned volumes:
|
||||
vol1
|
||||
vol2
|
||||
|
||||
Reclaimed 71.8 MB in disk space
|
||||
```
|
||||
|
||||
### `container volume list (ls)`
|
||||
|
||||
|
||||
Reference in new issue
Block a user