制作好镜像后,有时需要将镜像复制到另一台服务器使用,那么有两种方式:
一种是上传镜像到仓库中(本地仓库或远程公共仓库)
一种是将镜像保存为文件然后传到其他服务器上,再从文件中载入镜像;
可以使用Docker save和Docker load命令来存储和载入镜像。
第一种方式:私有仓库搭建
可配置加速器加速下载
/etc/docker/daemon.json
{
“registry-mirrors”: [“https://registry.docker-cn.com”]
}
下载registry镜像:
docker pull registry
docker pull docker.io/registry
这两个一样
启动镜像:
docker run -d -p 5000:5000 registry
然后可以通过restful接口查看仓库中的镜像(当前仓库是空的)
http://114.116.213.93:5000/v2/_catalog
私服仓库推送镜像
docker tag [imageId] 114.116.213.93:5000/cat/redis:latest
比如:
1、docker tag 6408fdc94212 127.0.0.1:5000/cat/tomcat:latest
2、docker push 127.0.0.1:5000/cat/tomcat:latest
[root@server docker]# docker tag 6408fdc94212 127.0.0.1:5000/cat/tomcat:latest
[root@server docker]#
[root@server docker]# docker push 127.0.0.1:5000/cat/tomcat:latest
The push refers to a repository [127.0.0.1:5000/cat/tomcat]
cd5b7e2631fa: Pushed
9f99f85da76a: Pushed
2c17ac16afc6: Pushed
2ee490fbc316: Pushed
b18043518924: Pushed
9a11244a7e74: Pushed
5f3a5adb8e97: Pushed
73bfa217d66f: Pushed
91ecdd7165d3: Pushed
e4b20fcc48f4: Pushed
latest: digest: sha256:8e75a9065fd732f2d06fccba994b246d77360b6e9870ac02b60b5b7d1fc6007d size: 2422
[root@server docker]
#查询镜像:
http://114.116.213.93:5000/v2/_catalog
查询刚才上传的镜像的版本
http://