pub async fn pull(
name: Reference,
image: bool,
image_group: bool,
layer_path: Option<PathBuf>,
) -> MicrosandboxResult<()>Expand description
Pulls an image or image group from a supported registry (Docker or Sandboxes.io).
This function handles pulling container images from different registries based on the provided parameters. It supports both single image pulls and image group pulls (for Sandboxes.io registry only).
For Sandboxes.io registry:
- Library repository images are pulled from Docker registry for compatibility
- Other namespaces are also pulled from Docker registry with a warning about potential future changes
§Arguments
name- The reference to the image or image group to pullimage- If true, indicates that a single image should be pulledimage_group- If true, indicates that an image group should be pulled (Sandboxes.io only)layer_path- The path to store the layer files
§Errors
Returns an error in the following cases:
- Both
imageandimage_groupare true (invalid combination) - Image group pull is requested for a non-Sandboxes.io registry
- Unsupported registry is specified
- Registry-specific pull operations fail
§Examples
use microsandbox_core::management::image;
use microsandbox_core::oci::Reference;
use std::path::PathBuf;
// Pull a single image from Docker registry
image::pull("docker.io/library/ubuntu:latest".parse().unwrap(), true, false, None).await?;
// Pull an image from Sandboxes.io registry
image::pull("sandboxes.io/library/alpine:latest".parse().unwrap(), true, false, None).await?;
// Pull an image from the default registry (when no registry is specified in the reference)
image::pull("nginx:latest".parse().unwrap(), true, false, None).await?;
// You can set the OCI_REGISTRY_DOMAIN environment variable to specify your default registry
std::env::set_var("OCI_REGISTRY_DOMAIN", "docker.io");
image::pull("alpine:latest".parse().unwrap(), true, false, None).await?;
// Pull an image from Docker registry and store the layers in a custom directory
image::pull("docker.io/library/ubuntu:latest".parse().unwrap(), true, false, Some(PathBuf::from("/custom/path"))).await?;