如果本地build的镜像需要共享的时候,就需要把镜像推送到镜像仓库,供其他人下载使用。
dockerHub就是这么一个东西。你可以将你的镜像设置为私有或者公有。
上传步骤
1、登录到dockerhub
docker 提供了客户端命令可以登录
[root@hadoop100 ~]#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: ninesun0318 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
2、给本地的镜像打一个tag
~]#docker tag 605c77e624dd ninesun0318/nginx-test
请注意两个镜像ID 是完全一样的
3、docker push 推送远端
]#docker push ninesun0318/nginx-test:latest
4、在dockerhub上查看.
5、使用完之后退出dockerhub
为了安全起见使用完应该退出,避免被hacker推送一些私密镜像到仓库
[root@hadoop101 qms]# docker logout
Removing login credentials for https://index.docker.io/v1/