CR supports image push, pull, and other operations through command-line tools. This topic describes how to push and pull images in CR using the mainstream command-line tool nerdctl.
Prerequisites
You need to first obtain the access domain name, namespace name, OCI artifact repository name, and other information for the CR instance. Then, use this information with nerdctl commands to push and pull images.
- A CR namespace has been created, and its name has been obtained. For details, see Creating namespaces.
tip
This topic uses macOS as an example to describe how to use CR through nerdctl. macOS does not support running nerdctl directly. You must use nerdctl with a virtual machine provided by Lima. For details, see nerdctl/macOS. Step 1: Log in to the CR instance
After obtaining the username, password, and access domain name of the CR instance, execute the following command to log in to the instance:
Example command
Example result
If Login Succeeded appears, the logon is successful.
Step 2: Obtain the image ID
Before pushing or pulling an image, obtain the ID of the image. In this example, the image ID is e3b7de64**** in the IMAGE ID column.
Command
Example output
Step 3: Set an image tag
Create an alias for the image in the target OCI artifact repository and set an image tag. In this example, the alias is enterprise-1-cn-guangzhou.cr.volces.com/vpc-****/vpc-j7w2****:nerdctl.
Command
Example command
Example output
After the command is executed, the new image appears under the target OCI artifact repository with the nerdctl tag.
Step 4: Push the image
Push the tagged image to CR.
Command
Example command
Example output
After the command is executed, you can view the pushed image in the console.
Step 5: Pull the image
After logging in to CR, you can also pull hosted images from it.
Command
Example command
Example output