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.

NetworksManager is the interface for creating and managing Podman container networks. It is accessible via client.networks on any PodmanClient instance. Networks define how containers communicate with each other and with external systems — you can configure drivers, DNS resolution, IPv6, and custom IP address management.

NetworksManager methods

create

create(name: string, options?: NetworkCreateOptions): Promise<Network>
Create a new network. Returns a Network instance.
name
string
required
Name of the network to create.
options.driver
string
Network driver to use (e.g. "bridge", "macvlan"). Defaults to "bridge" when omitted.
options.dnsEnabled
boolean
Enable DNS resolution for containers on this network.
options.networkDnsServers
string[]
Custom DNS server addresses used when dnsEnabled is true.
options.enableIpv6
boolean
Enable IPv6 on the network.
options.internal
boolean
Restrict external access — containers can only communicate with each other on this network.
options.labels
Record<string, string>
Metadata labels to attach to the network.
options.options
Record<string, string>
Driver-specific options passed through to the network backend.

list

list(options?: NetworkListOptions): Promise<Network[]>
List all networks.
options.filters
Record<string, string | string[]>
Key/value filters applied server-side (e.g. { name: "my-net", label: "env=prod" }).

get

get(key: string): Promise<Network>
Inspect a network by name or ID. Returns a Network instance. Throws NotFound if no matching network exists.

exists

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

remove

remove(name: string, options?: { force?: boolean }): Promise<void>
Delete a network by name.
options.force
boolean
Remove the network even if containers are still connected to it.

prune

prune(filters?: Record<string, string>): Promise<Record<string, unknown>>
Remove all unused networks. Optionally pass filters to narrow the set (e.g. { until: "24h" }). Returns a summary of removed networks and reclaimed space.

Network instance methods

A Network object is returned by create(), get(), and list(). It exposes the following methods:
MethodSignatureDescription
connect(containerId: string, options?: { aliases?: string[] }): Promise<void>Connect a container to the network. Optionally assign DNS aliases.
disconnect(containerId: string, options?: { force?: boolean }): Promise<void>Disconnect a container from the network.
inspect(): Promise<Record<string, unknown>>Return the full JSON inspect object from the Podman API.
update(options: { addDNSServers?: string[]; removeDNSServers?: string[] }): Promise<void>Update DNS servers or other mutable network settings.
remove(options?: { force?: boolean }): Promise<void>Delete this network.
reload(): Promise<void>Refresh network.attrs from the API.
network.id returns the network’s ID and network.name returns its name, both sourced from the inspect attributes.

IPAM configuration

podman-ts exports two classes — IPAMPool and IPAMConfig — for Internet Protocol Address Management. These map directly to Podman’s IPAM configuration structure and are provided for tooling compatibility when you need fine-grained control over IP subnets, ranges, and gateways.

IPAMPool

IPAMPool defines a single IP address pool for a network subnet.
import { IPAMPool } from "@pratyay360/podman-ts";

const pool = new IPAMPool({
  subnet: "10.10.0.0/24",
  iprange: "10.10.0.128/25",
  gateway: "10.10.0.1",
  auxAddresses: { "reserved-host": "10.10.0.200" },
});
OptionTypeDescription
subnetstringCIDR subnet (e.g. "192.168.100.0/24").
iprangestringAllocatable range within the subnet.
gatewaystringGateway address for the subnet.
auxAddressesRecord<string, string>Named auxiliary addresses reserved outside the allocatable range.

IPAMConfig

IPAMConfig groups one or more IPAMPool instances under a named driver.
import { IPAMConfig, IPAMPool } from "@pratyay360/podman-ts";

const ipam = new IPAMConfig({
  driver: "host-local",
  poolConfigs: [
    new IPAMPool({ subnet: "10.10.0.0/24", gateway: "10.10.0.1" }),
  ],
});
OptionTypeDefaultDescription
driverstring"host-local"IPAM driver name.
poolConfigsIPAMPool[][]One or more pool configurations.
optionsRecord<string, unknown>{}Driver-specific options.
Pass the constructed IPAMConfig object in options.options when calling client.networks.create() to configure custom address pools.

Code examples

Create a bridge network with DNS enabled

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

const client = new PodmanClient();

const network = await client.networks.create("app-net", {
  driver: "bridge",
  dnsEnabled: true,
  labels: { env: "production" },
});

console.log("Created network:", network.name, network.id);

Create a network with a custom IPAM pool

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

const client = new PodmanClient();

const pool = new IPAMPool({
  subnet: "10.88.0.0/24",
  gateway: "10.88.0.1",
  iprange: "10.88.0.128/25",
});

const ipam = new IPAMConfig({
  driver: "host-local",
  poolConfigs: [pool],
});

const network = await client.networks.create("custom-subnet-net", {
  driver: "bridge",
  dnsEnabled: true,
  options: { ipam: JSON.stringify(ipam) },
});

Connect and disconnect a container

const network = await client.networks.get("app-net");

// Connect a container, optionally assigning DNS aliases
await network.connect("my-container", { aliases: ["web", "frontend"] });

// Disconnect the container
await network.disconnect("my-container");

List and filter networks

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

for (const net of networks) {
  console.log(net.name, net.id);
}

Remove a network

// Remove by name via the manager
await client.networks.remove("app-net");

// Or via a Network instance — force-remove even with connected containers
const network = await client.networks.get("app-net");
await network.remove({ force: true });

Build docs developers (and LLMs) love