怎么把宿主机上的镜像推送到hub上:
1.查看系统中存在的镜像:
[root@izuf63bjp8ts8nkl13pxh1z devicemapper]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos-tomcat latest 1b49d3d12b9b 2 hours ago 575.3 MB
2.登陆docker—hub:
[root@izuf63bjp8ts8nkl13pxh1z devicemapper]# 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 (afangxin):
Password:
Login Succeeded
3.之前一直push失败,就是因为没有docker tag :
[root@izuf63bjp8ts8nkl13pxh1z devicemapper]# docker tag 1b49d3d12b9b afangxin/centos-tomcat
说明:1b49d3d12b9b是指镜像id号。这个步骤的目的是,把docker.io/centos-tomcat 变成 afangxin/centos-tomcat。 因为你要上传到hub上的用户名是afangxin
之前一直push失败,就是因为没有把宿主机上的docker.io 改成hub上的用户名afangxin 。
4.再次查看宿主机上的镜像,发现多了一个镜像 : angxin/centos-tomcat
[root@izuf63bjp8ts8nkl13pxh1z devicemapper]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
afangxin/centos-tomcat latest 1b49d3d12b9b 2 hours ago 575.3 MB
docker.io/centos-tomcat latest 1b49d3d12b9b 2 hours ago 575.3 MB
5.这时就可以push到hub上了:
[root@izuf63bjp8ts8nkl13pxh1z devicemapper]# docker push afangxin/centos-tomcat
The push refers to a repository [docker.io/afangxin/centos-tomcat]
2964e6cc937b: Pushed
080d1d3f3641: Pushed
7e824466c572: Pushing [> ] 526.6 kB/383.3 MB
5ac7fafec696: Pushed
e579f972c02a: Pushed
34e7b85d83e4: Mounted from library/centos
34e7b85d83e4: Preparing