docker 系列6 上传镜像

一.介绍

  本节主要介绍Docker镜像的push子命令,可以使用 docker [image] push命令上传镜像到仓库,默认上传到Docker hub官方仓库(需要登录)。命令格式 为docker [image] push NAME[:TAG]  | [REGISTRY_HOST[:REGISTRY_PORT]/] NAME[:TAG]。

  用户在docker hub网站注册后可以上传自制的镜像。

  文档:https://docs.docker.com/engine/reference/commandline/push/

  例如我的docker hub 的用户名为:hushaoren,先登录

[root@VM_0_12_centos ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: hushaoren
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

  将原有的镜像hello-world上传到仓库,先传前需要使用docker tag 将要发布的镜像改到自己账户名下。创建后再查看如下所示:

[root@VM_0_12_centos ~]# docker tag hello-world hushaoren/hello-world
[root@VM_0_12_centos ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
hushaoren/hello-world   latest              bf756fb1ae65        3 months ago        13.3kB
hello-world             latest              bf756fb1ae65        3 months ago        13.3kB
hello-world             latest              bf756fb1ae65        3 months ago        13.3kB

  上传镜像成功

[root@VM_0_12_centos ~]# docker push  hushaoren/hello-world
The push refers to repository [docker.io/hushaoren/hello-world]
9c27e219663c: Mounted from library/hello-world 
latest: digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042 size: 525

  去docker hub官方网站查看

  

   如果要获取镜像,查看docker 系列3 

 

  

  

posted on 2022-12-19 17:14  花阴偷移  阅读(10)  评论(0编辑  收藏  举报

导航