安装容器运行时
常见的容器运行时包括以下3种,可以根据需求选择安装。
Docker
Containerd
CRI-O
docker常用操作
登录容器镜像服务实例。
docker login --username=crs-user test-registry-huadong1.crs.ctyun.cn
登录的用户名和密码为开通实例时设置的用户名和密码,如果忘记密码,可以在访问凭证页面重置密码。
拉取镜像。
docker pull test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
推送镜像。
docker tag <ImageId> test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
docker push test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
示例:
使用docker images命令查看本地镜像。
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest xxxxxxx 7 weeks ago 4.86MB
使用docker tag命令重命名镜像。
docker tag b539af69bc01 test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:v1
使用docker push命令推送镜像。
docker push test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:v1
ctr常用操作
拉取镜像。
ctr image pull --user tester test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
推送镜像。
ctr image tag <镜像名> test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
ctr image push --user tester test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
示例:
使用ctr image ls命令查看本地镜像。
ctr image ls
REF TYPE DIGEST SIZE PLATFORMS LABELS
docker.io/library/busybox:latest application/vnd.docker.dist... sha256:3fbc632167424... 2.1 MiB linux/amd6 -
使用ctr image tag命令重命名镜像。
ctr image tag docker.io/library/busybox:latest test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:v1
使用ctr image push命令推送镜像。
ctr image push --user tester test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:v1
nerdctl常用操作
登录容器镜像服务实例。
nerdctl login --username=tester test-registry-huadong1.crs.ctyun.cn
拉取镜像。
nerdctl pull test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
推送镜像。
nerdctl tag <ImageId> test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
nerdctl push test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:<版本号>
示例:
使用nerdctl images命令查看本地镜像。
nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
busybox latest xxxxx 11 hours ago linux/amd64 4.2 MiB 2.1 MiB
使用nerdctl tag命令重命名镜像。
nerdctl tag 3fbc63216742 test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:v1
使用nerdctl push命令推送镜像。
nerdctl push test-registry-huadong1.crs.ctyun.cn/ns-test/repo-test:v1
Helm常用操作
需要使用Helm 3.7及以上客户端版本推送和拉取Chart。对于Helm 3.7版本,需要在环境变量中设置HELM_EXPERIMENTAL_OCI以启用OCI试验性支持:
export HELM_EXPERIMENTAL_OCI=1
对于Helm 3.8及以上版本无需进行此设置。
登录容器镜像服务实例。
helm registry login -u tester test-registry-huadong1.crs.ctyun.cn
登录的用户名和密码为开通实例时设置的用户名和密码,如果忘记密码,可以在访问凭证页面重置密码。
创建Chart并制作压缩包。
helm create test
tar -zcvf test.tgz test
推送 Chart。
helm push test.tgz oci://test-registry-huadong1.crs.ctyun.cn/testChart
拉取Chart。
helm pull oci://test-registry-huadong1.crs.ctyun.cn/testChart/test --version <版本号>
解压压缩包。
tar -xzvf test-<版本号>.tgz