首先,我们需要在(Docker Hub)上面注册一个用户,我这里面用的用户名为cnskylee

        然后,我们在一台安装并启动了docker的虚拟机里面(虚拟机可以连接外网),将本地的一个镜像上传到docker-hub。之所以需要上传镜像到docker-hub,是因为谷歌的镜像仓库(k8s.gcr.io)在国内无法访问和下载镜像。所以,需要在docker-hub上分享这部分镜像文件包。

 过程命令:

---重命名镜像文件
# docker tag k8s.gcr.io/metrics-server/metrics-server:v0.5.0 cnskylee/metrics-server:v0.5.0
# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED        SIZE
cnskylee/metrics-server                    v0.5.0    1c655933b9c5   6 months ago   63.5MB
k8s.gcr.io/metrics-server/metrics-server   v0.5.0    1c655933b9c5   6 months ago   63.5MB

---登录到docker-hub
# docker login -u cnskylee
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

---上传镜像到docker-hub
# docker push cnskylee/metrics-server:v0.5.0
The push refers to repository [docker.io/cnskylee/metrics-server]
d8de84e4db30: Pushed 
417cb9b79ade: Pushed 
v0.5.0: digest: sha256:05bf9f4bf8d9de19da59d3e1543fd5c140a8d42a5e1b92421e36e5c2d74395eb size: 739
[root@srvawxnd02 ~]# docker rmi cnskylee/metrics-server:v0.5.0
Untagged: cnskylee/metrics-server:v0.5.0
Untagged: cnskylee/metrics-server@sha256:05bf9f4bf8d9de19da59d3e1543fd5c140a8d42a5e1b92421e36e5c2d74395eb

---从docker-hub下载镜像测试
# docker pull cnskylee/metrics-server:v0.5.0
v0.5.0: Pulling from cnskylee/metrics-server
5dea5ec2316d: Pull complete 
2ca785997557: Pull complete 
Digest: sha256:05bf9f4bf8d9de19da59d3e1543fd5c140a8d42a5e1b92421e36e5c2d74395eb
Status: Downloaded newer image for cnskylee/metrics-server:v0.5.0
docker.io/cnskylee/metrics-server:v0.5.0

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐