DockerHub
https://hub.docker.com/ 注册账号
1、登录docker
[root@--- ~]# docker login --help
Usage: docker login [OPTIONS] [SERVER]
Log in to a Docker registry.
If no server is specified, the default is defined by the daemon.
Options:
-p, --password string Password
--password-stdin Take the password from stdin
-u, --username string Username
[root@--- ~]#
[root@--- ~]# docker login -u xiaobluewhale
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
[root@--- ~]#
2、服务器上提交镜像
docker push [OPTIONS] NAME[:TAG]
docker push命令推送镜像的规范是:注册用户名/镜像名。
使用以下方法之一命名您的本地镜像:
当你构建它们时,使用 docker build -t <hub-user>/<repo-name>[:<tag>]
重命名现有的本地镜像 docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]
通过docker commit <existing-container> <hub-user>/<repo-name>[:<tag>] 用于提交更改
docker push <hub-user>/<repo-name>:<tag>
docker push xiao/tomcat
Using default tag: latest
The push refers to repository [docker.io/xiao/tomcat]
69421fc728fb: Preparing
1f6217f0c2bb: Preparing
aa9c3f9fafec: Preparing
7d4a4cd414a9: Preparing
74ddd0ec08fa: Preparing
denied: requested access to the resource is denied # 拒绝
#推送失败的原因: name必须是注册用户名
#解决push失败问题
#增加一个tag, 重命名镜像
docker tag 24b3a476f143 xiaobluewhale/tomcat:1.0
The push refers to repository [docker.io/xiaobluewhale/tomcat]
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xiaobluewhale/tomcat 1.0 24b3a476f143 13 hours ago 680MB
xiao/tomcat 1.0 24b3a476f143 13 hours ago 680MB
xiao/tomcat latest 24b3a476f143 13 hours ago 680MB
#推送镜像
docker push xiaobluewhale/tomcat:1.0
提交的时候也是按照镜像的层级提交的
在个人DockerHub上查看推送成功的镜像