Authenticate with container registries, configure default registries, and manage registry credentials
Container Kit provides comprehensive registry management for pulling and pushing container images from public and private registries. Configure authentication, set default registries, and manage multiple registry credentials.
The registry system integrates with Apple’s container CLI to support Docker Hub, GitHub Container Registry (GHCR), Quay.io, and other OCI-compatible registries.
import { getDefaultRegistry } from '$lib/services/containerization/registry/default';const result = await getDefaultRegistry();if (!result.error) { const registry = JSON.parse(result.stdout); console.log('Default registry:', registry);}
Executes:
container registry default inspect
Configure a default registry:
import { setDefaultRegistry } from '$lib/services/containerization/registry/default';// Set Docker Hub as defaultconst result = await setDefaultRegistry('docker.io');// Set GitHub Container Registryconst result = await setDefaultRegistry('ghcr.io');// Set private registryconst result = await setDefaultRegistry('registry.company.com');if (!result.error) { console.log('Default registry updated');}
Executes:
container registry default set docker.io
Remove the default registry configuration:
import { unsetDefaultRegistry, removeDefaultRegistry, clearDefaultRegistry} from '$lib/services/containerization/registry/default';// All three functions are equivalentconst result = await unsetDefaultRegistry('docker.io');if (!result.error) { console.log('Default registry cleared');}
The login function uses --password-stdin for secure password input:
// Password is passed via stdin, never exposed in process listconst result = await registryLogin({ registry: 'ghcr.io', username: 'github-user', password: process.env.GITHUB_TOKEN, // Use environment variable scheme: 'https'});
Always use environment variables or secure credential storage for passwords. Never hardcode credentials in source code.
// Automatically detect HTTP or HTTPSconst result = await registryLogin({ registry: 'docker.io', username: 'user', password: 'pass', scheme: 'auto'});
Use scheme: 'auto' for most cases. The container CLI will automatically detect the appropriate protocol. Use 'https' explicitly for security-critical environments.