发布镜像到Docker Hub
Docker Hub
1、地址https://hub.docker.com/,注册自己的账号
账号:xxx
2、确定这个账号可以登录
3、在服务器上提交镜像
[root@iZbp171s854seavehj9wvqZ ~]# 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
# -u 账号 -p 密码
[root@iZbp171s854seavehj9wvqZ ~]# docker login -u 账号 -p 密码
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
4、登录完毕就可以提交镜像,docker push命令
# 推送到自己的镜像服务器上!
[root@iZbp171s854seavehj9wvqZ ~]# docker push 镜像名称
Using default tag: latest
The push refers to repository [docker.io/library/jzytomcat]
920334bd67dd: Preparing
5fb7c023055a: Preparing
e2de95481e4a: Preparing
e4cd2fee6b9f: Preparing
174f56854903: Preparing
denied: requested access to the resource is denied #拒绝
#无版本和推送用户信息的推送会被拒绝
#push镜像问题
[root@iZbp171s854seavehj9wvqZ ~]# docker push jzytomcatcc
Using default tag: latest
The push refers to repository [docker.io/library/jzytomcatcc]
An image does not exist locally with the tag: jzytomcatcc
#tag信息一定要先准备好
#添加tag信息和修改镜像名
[root@iZbp171s854seavehj9wvqZ ~]# docker tag c43cf5196ca3 xxx/tomcat:1.0
#docker push上去即可!发布的镜像尽量带上版本号
[root@iZbp171s854seavehj9wvqZ ~]# docker push xxx/tomcat:1.0
The push refers to repository [docker.io/xxx/tomcat]
920334bd67dd: Pushed
5fb7c023055a: Pushed
e2de95481e4a: Pushed
e4cd2fee6b9f: Pushed
174f56854903: Pushed
1.0: digest: sha256:2c6d2a983d6acd6566f756616079aff9e800b94a41d31d44e6be3b960a69a399 size: 1373
在自己的docker hub账号上看到对应镜像就是完成