Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pratyay360/podman-ts/llms.txt

Use this file to discover all available pages before exploring further.

VolumesManager is the interface for managing Podman volumes. Access it via client.volumes on any PodmanClient instance. Volumes provide persistent, named storage that outlives individual containers and can be shared across them.

VolumesManager methods

list

list(options?: VolumeListOptions): Promise<Volume[]>
Return all volumes visible to the Podman daemon.
options.filters
Record<string, string | string[]>
Key/value filters applied server-side. Common keys include name, driver, and label.

create

create(name?: string, options?: VolumeCreateOptions): Promise<Volume>
Create a named volume and return a Volume instance. If name is omitted, Podman generates one.
name
string
Volume name. If omitted, Podman assigns a random name.
options.driver
string
Volume driver to use (e.g. "local"). Defaults to the daemon’s default driver.
options.driverOpts
Record<string, string>
Driver-specific options passed through to the selected driver.
options.labels
Record<string, string>
Labels to attach to the volume.

get

get(volumeId: string): Promise<Volume>
Load a volume by name. Throws NotFound if the volume does not exist.

exists

exists(key: string): Promise<boolean>
Return true if a volume with the given name exists, false otherwise.

remove

remove(name: string, options?: { force?: boolean }): Promise<void>
Remove a volume by name.
options.force
boolean
Remove the volume even if it is in use by a container.

prune

prune(filters?: Record<string, string>): Promise<Record<string, unknown>>
Remove all unused volumes. Optionally pass filters to narrow the set (e.g. { label: "env=dev" }). Returns a summary of removed volumes and reclaimed disk space.
prune() is irreversible. Any data stored in unused volumes will be permanently deleted.

Volume instance methods

A Volume object is returned by create(), get(), and list(). It exposes the following methods:
MethodSignatureDescription
inspect(): Promise<Record<string, unknown>>Return the full JSON inspect object from the Podman API.
remove(options?: { force?: boolean }): Promise<void>Remove this volume. Pass force: true to remove even if in use.
reload(): Promise<void>Refresh volume.attrs from the API. Throws NotFound if the volume no longer exists.
export(): Promise<ArrayBuffer>Export the volume contents as a tar archive.
importTar(data: ArrayBuffer | Uint8Array): Promise<void>Import volume contents from a tar archive.
The volume.name property returns the volume’s name string. volume.id is an alias for volume.name.

Code examples

Create a named volume

import { PodmanClient } from "@pratyay360/podman-ts";

const client = new PodmanClient();

const volume = await client.volumes.create("my-data");
console.log("Created volume:", volume.name);

Create a volume with a custom driver and labels

const volume = await client.volumes.create("app-cache", {
  driver: "local",
  driverOpts: {
    type: "tmpfs",
    device: "tmpfs",
  },
  labels: {
    env: "production",
    app: "my-service",
  },
});

console.log("Volume:", volume.name);
Driver options are passed directly to the underlying storage driver. Consult your driver’s documentation for supported keys.

List volumes

// List all volumes
const all = await client.volumes.list();

// List only volumes with a specific label
const filtered = await client.volumes.list({
  filters: { label: "env=production" },
});

for (const vol of filtered) {
  console.log(vol.name);
}

Inspect and remove a volume

const volume = await client.volumes.get("my-data");

// Inspect returns the full Podman API JSON object
const info = await volume.inspect();
console.log("Mountpoint:", info.Mountpoint);

// Remove the volume when it's no longer needed
await volume.remove();
Removing a volume that is still mounted by a running container will fail unless force: true is passed.

Build docs developers (and LLMs) love