1.首先需要到hub docker创建账号和密码
由于我们生活在富强而自立的×××,所以所以要挂一个代理才能顺利注册,因为注册的时候需要有一个google的验证插件。
2.修改镜像名称
前方高能:
首先要在docker官网上创建一个仓库,根据自己的需要填写。
仓库名称:顾名思义,仓库名称
公有镜像:所有网友都可以搜到你的镜像
私有镜像:只有自己才能看到这个镜像
创建:就是创建这个仓库了。
3.编辑镜像tag
如果你的用户名是AAA,镜像名称是BBB,那么你的镜像的要改成AAA/BBB
4.登录docker
root@localhost ~]# 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: xinsir8
Password:
Login Succeeded
5.push镜像
[root@localhost ~]# docker push xinsir8/nginx2
The push refers to a repository [docker.io/xinsir8/nginx2]
3de6e80e42f9: Pushed
f12c6cf07176: Pushed
341dde1390a8: Pushed
9c46f426bcb7: Pushed
latest: digest: sha256:1d79f729c2e685bd07778430a1be25dfe23ce50031d21549ce22ffc18f2053e9 size: 1155
报错:
[root@localhost ~]# docker push xinsir8/nginx2
The push refers to a repository [docker.io/xinsir8/nginx2]
3de6e80e42f9: Preparing
f12c6cf07176: Preparing
341dde1390a8: Preparing
9c46f426bcb7: Preparing
denied: requested access to the resource is denied
解决办法:
执行第四步,再push就可以了。