Manage persistent storage and data volumes for your containers
Container Kit provides volume management capabilities for persistent data storage in macOS containers. Volumes allow you to persist data beyond the container lifecycle and share data between containers.
Volumes in Container Kit integrate with Apple’s container system to provide persistent storage solutions. Unlike container filesystems, volumes persist even when containers are removed, making them ideal for databases, application data, and shared resources.
// Container with database volume mount// Volume typically mounted at /var/lib/postgresql/data// or /var/lib/mysql depending on database typeconst result = await inspectContainer('postgres-container');const config = JSON.parse(result.stdout);// Check mount points for data directoryconsole.log('Data mounts:', config.configuration.mounts);
Database volumes ensure data persistence even when containers are recreated or upgraded.
Store application configuration and user data:
// Application containers with persistent config// Mounts typically include:// - /app/config// - /app/data// - /app/logsconst result = await inspectContainer('app-container');const mounts = JSON.parse(result.stdout).configuration.mounts;mounts.forEach(mount => { console.log('Mount point:', mount);});
Share data between multiple containers:
// Multiple containers can mount the same volume// Useful for:// - Shared configuration files// - Inter-container communication// - Log aggregationconst containers = ['web-1', 'web-2', 'web-3'];for (const containerId of containers) { const result = await inspectContainer(containerId); const config = JSON.parse(result.stdout); console.log(`${containerId} mounts:`, config.configuration.mounts);}
import { removeContainer, inspectContainer } from '$lib/services/containerization/containers';// Before removal - check volume mountsconst beforeResult = await inspectContainer('my-container');const mounts = JSON.parse(beforeResult.stdout).configuration.mounts;console.log('Volumes before removal:', mounts);// Remove containerawait removeContainer('my-container');// Volumes still exist and can be mounted to new containers// Data is preserved
Removing a container does NOT remove its volumes. This ensures data safety and allows for container recreation without data loss.