DockerHub
https://hub.docker.com/ 注册账号

1、登录docker

  1. [root@--- ~]# docker login --help
  2. Usage: docker login [OPTIONS] [SERVER]
  3. Log in to a Docker registry.
  4. If no server is specified, the default is defined by the daemon.
  5. Options:
  6. -p, --password string Password
  7. --password-stdin Take the password from stdin
  8. -u, --username string Username
  9. [root@--- ~]#
  10. [root@--- ~]# docker login -u xiaobluewhale
  11. Password:
  12. WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
  13. Configure a credential helper to remove this warning. See
  14. https://docs.docker.com/engine/reference/commandline/login/#credentials-store
  15. Login Succeeded
  16. [root@--- ~]#

2、服务器上提交镜像

docker push [OPTIONS] NAME[:TAG]
docker push命令推送镜像的规范是:注册用户名/镜像名。

  1. 使用以下方法之一命名您的本地镜像:
  2. 当你构建它们时,使用 docker build -t <hub-user>/<repo-name>[:<tag>]
  3. 重命名现有的本地镜像 docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]
  4. 通过docker commit <existing-container> <hub-user>/<repo-name>[:<tag>] 用于提交更改
  5. docker push <hub-user>/<repo-name>:<tag>
  1. docker push xiao/tomcat
  2. Using default tag: latest
  3. The push refers to repository [docker.io/xiao/tomcat]
  4. 69421fc728fb: Preparing
  5. 1f6217f0c2bb: Preparing
  6. aa9c3f9fafec: Preparing
  7. 7d4a4cd414a9: Preparing
  8. 74ddd0ec08fa: Preparing
  9. denied: requested access to the resource is denied # 拒绝
  10. #推送失败的原因: name必须是注册用户名
  11. #解决push失败问题
  12. #增加一个tag, 重命名镜像
  13. docker tag 24b3a476f143 xiaobluewhale/tomcat:1.0
  14. The push refers to repository [docker.io/xiaobluewhale/tomcat]
  15. docker images
  16. REPOSITORY TAG IMAGE ID CREATED SIZE
  17. xiaobluewhale/tomcat 1.0 24b3a476f143 13 hours ago 680MB
  18. xiao/tomcat 1.0 24b3a476f143 13 hours ago 680MB
  19. xiao/tomcat latest 24b3a476f143 13 hours ago 680MB
  20. #推送镜像
  21. docker push xiaobluewhale/tomcat:1.0

image.png
提交的时候也是按照镜像的层级提交的
在个人DockerHub上查看推送成功的镜像
image.png