docker打包镜像上传到私库

这里使用prometheus-operator打包镜像为例

1. 查找镜像

docker images|grep -E “quay|grafana/grafana”| awk ‘{print $1}’

[root@docker161 prometheus]# docker images|grep -E "quay|grafana"| awk '{print $1}'
192.168.1.161:5000/quay.io/coreos/prometheus-operator
192.168.1.161:5000/quay.io/coreos/grafana-watcher
192.168.1.161:5000/grafana/grafana
192.168.1.161:5000/quay.io/coreos/prometheus-config-reloader
192.168.1.161:5000/quay.io/prometheus/alertmanager
192.168.1.161:5000/quay.io/prometheus/prometheus
192.168.1.161:5000/quay.io/coreos/kube-state-metrics
192.168.1.161:5000/quay.io/prometheus/node-exporter

其他常用查找命令

#打印出prometheus-operator需要的镜像
docker images|grep -E "quay|grafana/grafana"| awk '{print $1}'

#打印出prometheus-operator需要的镜像,共9个镜像
[root@docker176 ~]# docker images|grep -E "quay|grafana/grafana"| awk '{print $1}'
[root@docker176 ~]# docker images|grep -E "quay|grafana"|grep -v "heapster-grafana-amd64"| awk '{print $1}'

2.打包镜像

将所有找到的镜像打包到prometheus-operator-v0.11.3.images.tar.gz

docker images|grep -E "quay|grafana/grafana"| awk '{print $1}' | xargs docker save -o prometheus-operator-v0.11.3.images.tar.gz

3. 上传到私服服务器上

scp ./prometheus-operator-v0.11.3.images.tar.gz [email protected]:/dir1/dir2/
指定文件名
scp ./prometheus-operator-v0.11.3.images.tar.gz [email protected]:/dir1/dir2/prometheus-operator.images.tar.gz

4. docker载入镜像

prometheus-operator-v0.11.3.images.tar.gz为服务器上的文件名

docker load -i prometheus-operator-v0.11.3.images.tar.gz 

你可能感兴趣的:(linux,docker)