实验:将镜像上传至私有仓库
1. docker tag teng_test 172.7.15.106:5000/centos //标记一下tag必须要带有私有仓库的ip:port
2. docker push 172.7.15.106:5000/centos //此时报错了类似如下
Error response from daemon: invalid registry endpoint https://172.7.15.106:5000/v0/: unable to ping registry endpoint https://172.7.15.106:5000/v0/
v2 ping attempt failed with error: Get https://172.7.15.106:5000/v2/: EOF
v1 ping attempt failed with error: Get https://172.7.15.106:5000/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 172.7.15.106:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/172.7.15.106:5000/ca.crt
我们挂载目录时可以指定容器name,不指定就系统随机生成了;
docker run -itd --volumes-from jolly teng /bin/bash //启用,--volumes-from启用数据卷选项
docker run -itd -v /data/:/mnt/ --name jolly [teng] bash //挂载数据卷,自定义容器name 3、定义数据卷容器
有时我们需要多个容器之间共享数据,就可以搭建一个专门 数据卷容器(仅共享),供其他容器挂载
docker run -itd -v /data --name testvol teng bash //新建,data是容器目录,非本地data
docker run -itd --volumes-from --name=web1 testvol teng //新建其他容器并 挂载数据卷容器 4、数据卷的备份与恢复
原理:(三重保护)
其他容器/data/ 挂载----数据卷容器/data/ 挂载---宿主机的/data/
备份容器/data/ 挂载----数据卷的/data/---用cron将data目录打包,存放至/bak下
备份容器/bak/ 挂载----宿主机的/bak
docker run -itd -v /data/ --name testvol2 teng /bin/bash //新建数据卷容器
docker run -itd --volumes-from testvol2 teng /bin/bash //挂载数据卷容器,可多个
docker run -itd -v /data/:/data/ testvol2 /bin/bash //数据卷容器挂载至本地
docker run --volumes-from testvol2 -v /bak/:/bak/ teng tar cvf /bak/data.tar /data/
//新建容器,挂载到数据卷容器/bak目录,然后压缩/data/目录
docker run --volumes-from testvol2 -v /data/:/data teng tar xvf /bak/data.tar