Activate the Docker registry
- Log in to the KCE console.
- In the left navigation pane, choose Image Repository > My Images. If you use the My Images feature for the first time, initialize the Docker registry and set a password for the Docker registry.
- User Name: the ID of your Kingsoft Cloud account, which cannot be changed.
- Password: the password that is used to log in to the Kingsoft Cloud Docker registry through docker login. The password can be customized. It must be 8 to 32 characters in length, and must contain at least two of the following types: letters, digits, and special characters. The special characters include !$% ()*+,–./:;<=>?@[]^_`{|}.
Create a namespace
Namespaces provide a scope for your private image addresses. Namespaces are used to group your container images.
- Log in to the KCE console.
- In the left navigation pane, choose Image Repository > Namespace.
- On the Namespace page, click Create Namespace.
- In the Create Namespace dialog box, set the following parameters:
- Name: the name of the namespace. It can be customized. It must be 4 to 30 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-). The name cannot start or end with an underscore (_) or a hyphen (-).
- Type: the type of the namespace. It determines the type of image repositories in the namespace.
- Click OK.
Create an image repository
- Log in to the KCE console.
- In the left navigation pane, choose Image Repository > My Images.
- On the My Images page, click Create Repository.
- In the Create Repository dialog box, set the following parameters:
- Name: the name of the image repository. It must be 2 to 30 characters in length, and can contain lowercase letters, digits, underscores (_), and hyphens (-). The name cannot start or end with an underscore (_) or a hyphen (-).
- Namespace: the namespace to which the image repository belongs.
- Type: the type of the image repository, which is the same as that of the namespace.
- Description: the description of the image repository.
- Click OK.
Push images to the Docker registry
Log in to the Kingsoft Cloud Docker registry
The region of Beijing is used as an example.
$ sudo docker login --username=[username] hub.kce.ksyun.com
username: the ID of your Kingsoft Cloud account. The login completes after you enter the password. The password is the one that you set when you activate the Docker registry.
Push an image
$ sudo docker tag [ImageId] hub.kce.ksyun.com/[namespace]/[ImageName]:[tag]
$ sudo docker push hub.kce.ksyun.com/[namespace]/[ImageName]:[tag]
ImageId: the actual image ID.
tag: the image version.
namespace: the name of the configured namespace.
ImageName: the name of the image created in the console.
Pull an image
$ sudo docker pull hub.kce.ksyun.com/[namespace]/[ImageName]:[tag]
tag: the version of the image that you want to pull.