docker提供了一个类似于github的仓库dockerhub, 网址https://hub.docker.com/需要注册使用
在linux中运行: docker login
[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: andy963
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
然后执行push命令:
[root@localhost ~]# docker push andy963/centos-vim:latest
注意,这里的andy963必须 与账户一致,如果不一致,就会出现下面的情况:
[root@localhost ~]# docker push andy/centos-vim:latest
The push refers to repository [docker.io/andy/centos-vim]
1af67517c2b5: Preparing
0683de282177: Preparing
denied: requested access to the resource is denied
我们修改tag:
[root@localhost ~]# docker tag andy/centos-vim andy963/centos-vim
再次上传:
[root@localhost ~]# docker push andy963/centos-vim:latest
The push refers to repository [docker.io/andy963/centos-vim]
1af67517c2b5: Pushing 18.38MB/60.45MB
0683de282177: Preparing
删除本地镜像,测试下载pull 镜像文件
docker pull andy963/centos-vim