Help Center/ Cloud Container Instance (CCI)/ Best Practices/ Image Management/ Using Image Snapshots to Accelerate Image Pull
Updated on 2025-04-07 GMT+08:00

Using Image Snapshots to Accelerate Image Pull

Scenario

Image snapshots provide a more efficient way to start up containers. Using an image snapshot to create a pod accelerates image pull and reduces the time required for starting up the containers. For details about how to use image snapshots, see Using Image Snapshots.

Procedure

  1. Log in to the CCI 2.0 console. In the navigation pane, choose Image Snapshots. On the displayed page, click Create from YAML. The following is an example YAML file:

    apiVersion: cci/v2
    kind: ImageSnapshot
    metadata:
      name: imagesnapshot-a
    spec:
      buildingConfig:
        namespace: default  # Namespace
      imageSnapshotSize: 20 # Image snapshot size, in GiB
      ttlDaysAfterCreated: 100 # Image validity period
      images:
        - image: nginx:stable-alpine-perl # Image
      registries: []

  2. In the navigation pane, choose Workloads. On the Deployments tab, click Create from YAML to create a workload. Add cci.io/image-snapshot-auto-match: 'true' in annotations. The following is an example:

    kind: Deployment
    apiVersion: cci/v2
    metadata:
      name: nginx
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
          annotations:
            cci.io/image-snapshot-auto-match: 'true' # Automatic matching of image snapshots
        spec:
          containers:
            - name: nginx
              image: nginx:stable-alpine-perl
              resources:
                requests:
                  cpu: 500m
                  memory: 1Gi

  3. Verify that the pod annotations contain the cci.io/image-snapshot-detail and cci.io/imagesnapshot-volume fields, the matched image snapshot is displayed, and the size of the mounted data disk is the same as that of the image snapshot.