Create SOCI indexes with nerdctl and SOCI CLI example
The following page provides an example on how to create SOCI indexes with nerdctl and SOCI CLI.
Create SOCI indexes example
-
First set your variables for the Amazon CLI commands that follow. The following is an example of setting up your variables.
ACCOUNT_ID="111122223333" REGION="us-east-1" REPOSITORY_NAME="repository-name" ORIGINAL_IMAGE_TAG="original-image-tag" SOCI_IMAGE_TAG="soci-indexed-image-tag"Variable definitions:
-
ACCOUNT_IDis your Amazon Web Services account ID -
REGIONis the Amazon Web Services Region of your Amazon ECR private registry -
REPOSITORY_NAMEis the name of your Amazon ECR private registry -
ORIGINAL_IMAGE_TAGis the tag of your original image -
SOCI_IMAGE_TAGis the tag of your SOCI-indexed image
-
-
Install required tools:
# Install SOCI CLI, containerd, and nerdctl sudo yum install soci-snapshotter sudo yum install containerd jq sudo systemctl start soci-snapshotter sudo systemctl restart containerd sudo yum install nerdctl -
Set your registry variables:
REGISTRY_USER=AWS REGISTRY="$ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com" -
Export your region and authenticate to Amazon ECR:
export AWS_REGION=$REGION REGISTRY_PASSWORD=$(/usr/local/bin/aws ecr get-login-password --region $AWS_REGION) echo $REGISTRY_PASSWORD | sudo nerdctl login -u $REGISTRY_USER --password-stdin $REGISTRY -
Pull your original container image:
sudo nerdctl pull $REGISTRY/$REPOSITORY_NAME:$ORIGINAL_IMAGE_TAG -
Create the SOCI index:
sudo nerdctl image convert --soci $REGISTRY/$REPOSITORY_NAME:$ORIGINAL_IMAGE_TAG $REGISTRY/$REPOSITORY_NAME:$SOCI_IMAGE_TAG -
Push the SOCI-indexed image:
sudo nerdctl push --platform linux/amd64 $REGISTRY/$REPOSITORY_NAME:$SOCI_IMAGE_TAG
This process creates two artifacts for the original container image in your ECR repository:
-
SOCI index - Metadata enabling lazy loading
-
Image Index manifest - OCI-compliant manifest