前一阵子搭建了一个harbor镜像仓库，并且写了搬砖脚本，只是提供一些运维用的到的镜像仓库。如果大家有需要，可以试试。如果需要一些运维工作相关的镜像，可以留言，我会及时同步。镜像仓库地址：harbor.op123.ren:44301 修改docker配置：cat <<'EOF'>/etc/docker/daemon.json { "debug": false, "experimental": true, "registry-mirrors": [ "https://harbor.op123.ren:44301" ] } EOF systemctl daemon-reload systemctl restart docker 如此一来，既方便大家使用，也可以丰富仓库内容。让运维工作更顺畅自然。脚本内容如下：#!/usr/bin/python3 # filename: dockerpullandpush.py # 部署在hk小鸡里 import docker import argparse import subprocess import json def pull_and_push_image(image_name, docker_username, docker_password, harbor_url, harbor_username, harbor_password): # 从 image_name 中提取 harbor_project if '/' in image_name: harbor_project = image_name.split('/')[0] image_name_without_project = '/'.join(image_name.split('/')[1:]) else: harbor_project = 'library' image_name_without_project = image_name # 创建 Docker 客户端 client = docker.from_env() # 登录 Docker Hub client.login(username=docker_username, password=docker_password) # 拉取镜像 print(f"Pulling image {image_name} from Docker Hub...") image = client.images.pull(image_name) # 标记镜像 harbor_image_name = f"{harbor_url}/{harbor_project}/{image_name_without_project}" image.tag(harbor_image_name) # 登录 Harbor client.login(username=harbor_username, password=harbor_password, registry=harbor_url) # 检查项目是否存在 project_exists_cmd = f"curl -s -u {harbor_username}:{harbor_password} -X GET https://{harbor_url}/api/v2.0/projects?name={harbor_project}" project_exists_output = subprocess.check_output(project_exists_cmd, shell=True) project_exists_data = json.loads(project_exists_output) if len(project_exists_data) == 0: # 如果项目不存在,则创建项目 print(f"Project {harbor_project} does not exist in Harbor. Creating...") create_project_cmd = f"curl -s -u {harbor_username}:{harbor_password} -X POST -H \"Content-Type: application/json\" -d '{{\"project_name\": \"{harbor_project}\", \"public\": true}}' https://{harbor_url}/api/v2.0/projects" subprocess.check_output(create_project_cmd, shell=True) print(f"Project {harbor_project} created successfully.") # 推送镜像到 Harbor print(f"Pushing image {harbor_image_name} to Harbor...") client.images.push(harbor_image_name) print("Image pulled and pushed successfully.") # 清理下载的容器镜像 print(f"Cleaning up downloaded image {image_name}...") client.images.remove(image_name) client.images.remove(harbor_image_name) print("Cleanup completed.") if __name__ == "__main__": parser = argparse.ArgumentParser(description="Pull images from Docker Hub and push them to Harbor.") parser.add_argument("image_names", nargs='+', help="Names of the images to pull and push") parser.add_argument("--docker-username", default="zzlyzq@126.com", help="Docker Hub username") parser.add_argument("--docker-password", default="xxx", help="Docker Hub password") parser.add_argument("--harbor-url", default="harbor.op123.ren:44301", help="Harbor URL") parser.add_argument("--harbor-username", default="admin", help="Harbor username") parser.add_argument("--harbor-password", default="xxx", help="Harbor password") args = parser.parse_args() for image_name in args.image_names: print(f"\nProcessing image: {image_name}") pull_and_push_image(image_name, args.docker_username, args.docker_password, args.harbor_url, args.harbor_username, args.harbor_password)
为了方便日常的工作等使用，搭建一个私域的容器镜像仓库。搭建的方法也简单。直接下载harbor离线安装包，解压，复制harbor.yml.sample文件，修改其中的域名、端口、证书等信息，然后运行install.sh，等待服务启动。写个脚本dockerpullandpush.py，通过运行+镜像名称，实现从dockerhub下载并上传到私钥harbor镜像仓库。脚本内容如下：#!/usr/bin/python3.7 import docker import argparse import subprocess import json def pull_and_push_image(image_name, docker_username, docker_password, harbor_url, harbor_username, harbor_password): # 从 image_name 中提取 harbor_project if '/' in image_name: harbor_project = image_name.split('/')[0] else: harbor_project = 'library' # 创建 Docker 客户端 client = docker.from_env() # 登录 Docker Hub client.login(username=docker_username, password=docker_password) # 拉取镜像 print(f"Pulling image {image_name} from Docker Hub...") image = client.images.pull(image_name) # 标记镜像 harbor_image_name = f"{harbor_url}/{harbor_project}/{image_name}" image.tag(harbor_image_name) # 登录 Harbor client.login(username=harbor_username, password=harbor_password, registry=harbor_url) # 检查项目是否存在 project_exists_cmd = f"curl -s -u {harbor_username}:{harbor_password} -X GET https://{harbor_url}/api/v2.0/projects?name={harbor_project}" project_exists_output = subprocess.check_output(project_exists_cmd, shell=True) project_exists_data = json.loads(project_exists_output) if len(project_exists_data) == 0: # 如果项目不存在,则创建项目 print(f"Project {harbor_project} does not exist in Harbor. Creating...") create_project_cmd = f"curl -s -u {harbor_username}:{harbor_password} -X POST -H \"Content-Type: application/json\" -d '{{\"project_name\": \"{harbor_project}\", \"public\": true}}' https://{harbor_url}/api/v2.0/projects" subprocess.check_output(create_project_cmd, shell=True) print(f"Project {harbor_project} created successfully.") # 推送镜像到 Harbor print(f"Pushing image {harbor_image_name} to Harbor...") client.images.push(harbor_image_name) print("Image pulled and pushed successfully.") # 清理下载的容器镜像 print(f"Cleaning up downloaded image {image_name}...") client.images.remove(image_name) client.images.remove(harbor_image_name) print("Cleanup completed.") if __name__ == "__main__": parser = argparse.ArgumentParser(description="Pull an image from Docker Hub and push it to Harbor.") parser.add_argument("image_name", help="Name of the image to pull and push") parser.add_argument("--docker-username", default="zzlyzq@126.com", help="Docker Hub username") parser.add_argument("--docker-password", default="xxxxxxxxxx", help="Docker Hub password") parser.add_argument("--harbor-url", default="harbor.op123.ren:44301", help="Harbor URL") parser.add_argument("--harbor-username", default="xxx", help="Harbor username") parser.add_argument("--harbor-password", default="xxx", help="Harbor password") args = parser.parse_args() pull_and_push_image(args.image_name, args.docker_username, args.docker_password, args.harbor_url, args.harbor_username, args.harbor_password)方便使用，可以直接将该仓库作为默认镜像仓库，修改/etc/docker/daemon.json内容如下：cat <<'EOF'>/etc/docker/daemon.json { "debug": true, "experimental": true, "registry-mirrors": [ "https://harbor.op123.ren:44301"], "log-opts":{"max-size":"100m","max-file":"1"} } 参考https://blog.csdn.net/weixin_43798031/article/details/128161625
ARM, AArch64, 和 x86_64 都是计算机处理器的架构。它们定义了处理器如何处理数据，如何执行指令，以及如何与其他硬件交互。ARM: ARM 是 Advanced RISC Machine 的缩写，它是一种采用 RISC（Reduced Instruction Set Computing，精简指令集计算）设计的处理器架构。ARM 架构的处理器通常在移动设备（如智能手机和平板电脑）和嵌入式系统（如路由器和物联网设备）中使用，因为它们通常具有较低的功耗。AArch64: AArch64 是 ARMv8 架构中的 64 位模式，它是 ARM 架构的扩展。AArch64 支持更多的寄存器，以及更大的内存寻址空间，这使得它在需要处理大量数据的应用（如图形处理和机器学习）中具有优势。x86_64: x86_64 也被称为 AMD64 或 x64，它是 x86 架构的 64 位版本。x86 架构最初由 Intel 开发，最早的版本是 16 位的，后来扩展到 32 位（即 IA-32 或 x86），最后扩展到 64 位（即 x86_64）。x86_64 架构的处理器在个人电脑和服务器中广泛使用。除了这些，还有其他的处理器架构，例如：MIPS: MIPS 是 Microprocessor without Interlocked Pipelined Stages 的缩写，它也是一种采用 RISC 设计的处理器架构。MIPS 架构的处理器在很多嵌入式系统中使用。PowerPC: PowerPC 是一种由 Apple、IBM 和 Motorola 共同开发的 RISC 处理器架构。虽然现在在个人电脑中已经不常见，但它仍在一些嵌入式系统和高性能计算系统中使用。SPARC: SPARC 是 Scalable Processor Architecture 的缩写，它是一种由 Sun Microsystems 开发的 RISC 处理器架构。SPARC 架构的处理器主要在一些高端的服务器和工作站中使用。每种处理器架构都有其自己的优点和特点，选择哪种架构取决于特定的应用需求，如性能、功耗、成本等因素。现在有一个容器镜像，架构是amd64，那么对于os有没有要求？是否可以直接linux和windows里面使用呢？容器镜像的架构（例如 amd64）是指镜像是为哪种处理器架构构建的。这个架构需要与运行容器的主机的处理器架构相匹配。也就是说，如果你有一个为 amd64 架构构建的容器镜像，那么你需要在一个 amd64 架构的主机上运行它。至于操作系统，容器技术最初是在 Linux 上开发的，因为它依赖于 Linux 内核的一些特性，如 cgroups 和 namespaces。这意味着，如果你有一个为 Linux 构建的容器镜像，那么你需要在 Linux 主机上运行它。然而，随着容器技术的发展，Microsoft 在 Windows 10 和 Windows Server 2016 中引入了对 Windows 容器的支持。这意味着你可以在 Windows 主机上运行为 Windows 构建的容器镜像。但是，你不能在 Windows 主机上运行为 Linux 构建的容器镜像，反之亦然。如果你需要在 Windows 主机上运行 Linux 容器，你可以使用 Docker Desktop for Windows，它使用的是一个名为 MobyLinuxVM 的轻量级虚拟机来运行 Linux 容器。或者，你也可以使用 Windows Subsystem for Linux (WSL)，它允许你在 Windows 中运行 Linux 环境。总的来说，容器镜像的架构和操作系统都需要与运行容器的主机匹配。如果不匹配，你可能需要使用一些工具或技术来解决这个问题。WSL是一个linux虚拟机么？Windows Subsystem for Linux (WSL) 不是传统意义上的 Linux 虚拟机，它更像是一个兼容层，使得你可以在 Windows 系统上直接运行 Linux 二进制可执行文件。WSL 1 和 WSL 2 的工作原理有一些不同：WSL 1：WSL 1 是一个兼容层，它翻译 Linux 系统调用为 Windows 系统调用，然后让 Linux 二进制可执行文件在 Windows 内核上运行。这种方法的优点是性能开销小，但缺点是一些复杂的 Linux 系统调用（例如，那些涉及到文件系统或网络堆栈的）可能无法完全或正确地翻译。WSL 2：WSL 2 是一个轻量级虚拟机，它运行一个完整的 Linux 内核，并在其上运行 Linux 二进制可执行文件。这种方法的优点是兼容性更好（因为它使用的是真正的 Linux 内核），但缺点是有一些额外的性能开销（虽然 Microsoft 已经做了很多优化，使得这个开销尽可能小）。总的来说，你可以把 WSL 看作是一种让你在 Windows 中运行 Linux 环境的方法，不论是通过系统调用翻译（WSL 1），还是通过轻量级虚拟化（WSL 2）。WSL与cygwin对呢有何优缺点？Cygwin 和 Windows Subsystem for Linux (WSL) 都提供了在 Windows 环境中运行 Unix-like 环境的能力，但它们的实现方式和用途有所不同，因此各有优缺点。Cygwin:优点：Cygwin 提供了大量的 GNU 和开源工具，可以让你在 Windows 中使用 Unix-like 的环境。它不仅提供了 shell 环境和命令行工具，还提供了图形用户界面 (GUI) 应用程序的支持。Cygwin 可以在所有版本的 Windows 中运行，不需要特殊的硬件或操作系统支持。缺点：Cygwin 是一个模拟层，它模拟 Unix-like 的环境，而不是运行真正的 Linux 内核。因此，一些特定的 Linux 功能或应用可能无法在 Cygwin 中运行。Cygwin 的性能可能不如 WSL，特别是在处理大量的文件操作时。WSL:优点：WSL 提供了更接近真实 Linux 环境的体验。在 WSL 2 中，你甚至可以运行完整的 Linux 内核。WSL 的性能通常比 Cygwin 更好，特别是在处理大量的文件操作时。WSL 可以直接运行 Linux 二进制可执行文件，这意味着你可以在 WSL 中运行大多数 Linux 应用程序，无需任何修改。缺点：WSL 只在较新的 Windows 10 和 Windows Server 版本中可用。WSL 1 对某些 Linux 系统调用的支持可能不完全，虽然 WSL 2 改善了这个问题。WSL 不支持图形用户界面 (GUI) 应用程序，虽然有一些工具和方法可以解决这个问题。总的来说，Cygwin 和 WSL 提供了不同的功能和体验，适合不同的用途。你应该根据你的具体需求来选择使用哪一个。
为了更好的使用容器镜像，以及常见的收集习惯，尝试将dockerhub中的镜像，或者主要镜像同步到本地镜像仓库harbor。同步的方法主要是设定上游服务器docker.io，dockerproxy.com。缺点，两个都有限制。近期发现，AWS有ECS服务，地址public.ecr.aws部署下游harbor服务器，本地可以访问。设定一批待同步projects进入bash shell脚本的数组。通过docker-ls访问上游服务器并拿到tag列表，也访问下游harbor服务器并达到已有的tag列表，如果没有就进行pull，然后push操作。主要脚本内容如下：#!/bin/bash set -x harbor1="public.ecr.aws" harbor2="harbor.sddts.cn" docker login -u admin -p "xxx" harbor.sddts.cn projects=() projects+=("library/mysql" "library/alpine" "library/centos" "library/debian" "library/ubuntu" "library/python" "library/caddy" "library/redis" "library/nginx" "library/busybox" "library/postgres" "library/node" "library/memcached" "library/httpd" "library/mongo" "library/rabbitmq" "library/mariadb" "library/docker" "library/hello-world" "library/openjdk" "library/golang" "library/registry" "library/wordpress" "library/php" "library/consul" "library/influxdb" "library/haproxy" "library/tomcat" "library/maven" "library/bash" "library/ghost" "library/kong" "library/zookeeper" "jenkins/jenkins" "library/mediawiki" "library/django" "library/gcc") #projects+=("chaitin/safeline-tengine" "chaitin/safeline-mgt-api" "chaitin/safeline-detector" "chaitin/safeline-mario") #projects+=("jumpserver/lion" "jumpserver/koko" "jumpserver/guacamole" "jumpserver/core" "jumpserver/jms_all" "jumpserver/web" "jumpserver/redis" "jumpserver/nginx" "jumpserver/core" "jumpserver/mysql" "jumpserver/magnus" "jumpserver/mariadb" "jumpserver/luna" "jumpserver/guacamole" "jumpserver/lina" "jumpserver/chen" "jumpserver/kael" "jumpserver/guacd" "jumpserver/python" "jumpserver/jms_web") #projects+=("flashcatcloud/categraf" "flashcatcloud/nightingale" "flashcatcloud/ibex" "flashcatcloud/chatshot" "flashcatcloud/mock" "flashcatcloud/toolbox" "flashcatcloud/rocketmq-exporter" "flashcatcloud/public" "flashcatcloud/chrome" "flashcatcloud/scvpn" "flashcatcloud/scvpn" "flashcatcloud/wine" "flashcatcloud/kube-state-metric" "flashcatcloud/corplink" ) #projects+=("joyqi/typecho") #projects+=("joyqi/typecho" ) #projects+=("rustdesk/rustdesk-server" ) #projects+=("dreamacro/clash" ) #projects+=("yidadaa/chatgpt-next-web" ) #projects+=("grafana/promtail" "grafana/loki" "grafana/loki-canary" "grafana/loki-docker-driver" "grafana/loki-build-image" "grafana/loki-operator" "grafana/loki-query-tee" "grafana/loki-canary-boringcrypto" "grafana/loki-helm-test" "grafana/loki-bigtable-backup" "grafana/logstash-output-loki" ) #projects+=("headscale/headscale" ) #projects+=("homeassistant/home-assistant" "homeassistant/raspberrypi3-homeassistant" "homeassistant/qemux86-64-homeassistant" ) #projects+=("jasonrivers/nagios" ) #projects+=("jenkinsci/jenkins" ) #projects+=("rancher/rancher-agent" "rancher/fleet-agent" "rancher/rancher" "rancher/server" "rancher/pause" "rancher/fleet" "rancher/mirrored-pause" "rancher/os" "rancher/metrics-server" "rancher/k8s" "rancher/local-path-provisioner" "rancher/agent" "rancher/klipper-lb" "rancher/shell" "rancher/rancher-operator" "rancher/rke-tools" "rancher/calico-node" "rancher/rancher-webhook" "rancher/coredns-coredns" "rancher/net" "rancher/mirrored-coredns-coredns" "rancher/nginx-ingress-controller" "rancher/klipper-helm" "rancher/hyperkube" "rancher/calico-cni" "rancher/mirrored-metrics-server" "rancher/mirrored-calico-node" "rancher/mirrored-istio-proxyv2" "rancher/istio-proxyv2" "rancher/coreos-flannel" "rancher/system-agent-installer-rke2" "rancher/gitjob" "rancher/lb-service-haproxy" "rancher/mirrored-prometheus-node-exporter" "rancher/network-manager" "rancher/mirrored-library-busybox" "rancher/metadata" "rancher/rke2-runtime" "rancher/k3s" "rancher/calico-pod2daemon-flexvol" "rancher/healthcheck" "rancher/dns" "rancher/mirrored-calico-cni" "rancher/mirrored-library-nginx" "rancher/prom-prometheus" "rancher/mirrored-calico-pod2daemon-flexvol" "rancher/prom-node-exporter" "rancher/fluentd" "rancher/log-aggregator" "rancher/cluster-proportional-autoscaler" "rancher/kube-api-auth" "rancher/system-agent-installer-k3s" "rancher/mirrored-library-traefik" "rancher/nginx-ingress-controller-defaultbackend" "rancher/jimmidyson-configmap-reload" "rancher/rancher-runtime" "rancher/library-traefik" "rancher/mirrored-flannelcni-flannel-cni-plugin" "rancher/mirrored-flannelcni-flannel" "rancher/coreos-prometheus-config-reloader" "rancher/grafana-grafana" "rancher/longhorn-manager" "rancher/scheduler" "rancher/library-busybox" "rancher/prometheus-auth" "rancher/mirrored-prometheus-operator-prometheus-config-reloader" "rancher/mirrored-prometheus-prometheus" "rancher/mirrored-cluster-proportional-autoscaler" "rancher/metrics-server-amd64" "rancher/security-scan" "rancher/istio-kubectl" "rancher/mirrored-calico-kube-controllers" "rancher/container-crontab" "rancher/mirrored-cloud-provider-vsphere-csi-release-driver" "rancher/mirrored-grafana-grafana" "rancher/coreos-prometheus-operator" "rancher/configmap-reload" "rancher/coreos-kube-state-metrics" "rancher/pushprox-client" "rancher/hardened-kubernetes" "rancher/mirrored-kiwigrid-k8s-sidecar" "rancher/system-upgrade-controller" "rancher/pushprox-proxy" "rancher/kubectl" "rancher/mirrored-prometheus-alertmanager" "rancher/k3s-upgrade" "rancher/mirrored-kube-state-metrics-kube-state-metrics" "rancher/pause-amd64" "rancher/mirrored-fluent-fluent-bit" "rancher/cis-operator" "rancher/coreos-etcd" "rancher/nginx" "rancher/mirrored-prometheus-operator-prometheus-operator" "rancher/library-nginx" "rancher/kiali-kiali" "rancher/prom-alertmanager" "rancher/mirrored-coreos-flannel" "rancher/hardened-etcd" "rancher/rke2-upgrade" "rancher/mirrored-longhornio-longhorn-manager" "rancher/hardened-coredns" "rancher/flannel-cni" "rancher/k3d-tools" "rancher/hardened-calico" "rancher/storage-secrets" "rancher/mirrored-prometheus-adapter-prometheus-adapter" "rancher/hardened-flannel" "rancher/jenkins-jenkins" "rancher/curlimages-curl" "rancher/hello-world" "rancher/mirrored-prom-alertmanager" "rancher/calico-kube-controllers" "rancher/mirrored-neuvector-updater" "rancher/tekton-utils" "rancher/k3d-proxy" "rancher/mirrored-jimmidyson-configmap-reload" "rancher/agent-instance" "rancher/coreos-configmap-reload" "rancher/external-dns" "rancher/kopf" "rancher/rke2-cloud-provider" "rancher/istio-mixer" "rancher/mirrored-coreos-etcd" "rancher/rancher-ecr-credentials" "rancher/mirrored-directxman12-k8s-prometheus-adapter" "rancher/hardened-cluster-autoscaler" "rancher/banzaicloud-fluentd" "rancher/mirrored-nginx-ingress-controller-defaultbackend" "rancher/mirrored-longhornio-longhorn-instance-manager" "rancher/mirrored-cloud-provider-vsphere-csi-release-syncer" "rancher/backup-restore-operator" "rancher/etcd" "rancher/mirrored-ingress-nginx-kube-webhook-certgen" "rancher/pipeline-tools" "rancher/mirrored-longhornio-csi-node-driver-registrar" "rancher/hardened-k8s-metrics-server" "rancher/system-agent-installer-rancher" "rancher/storage-nfs" "rancher/jaegertracing-all-in-one" "rancher/mirrored-banzaicloud-fluentd" "rancher/rio-controller" "rancher/mirrored-longhornio-longhorn-engine" "rancher/k8s-dns-sidecar-amd64" "rancher/k8s-dns-kube-dns-amd64" "rancher/minio-minio" "rancher/jenkins-jnlp-slave" "rancher/k8s-dns-dnsmasq-nanny-amd64" "rancher/istio-pilot" "rancher/k8s-dns-dnsmasq-nanny" "rancher/k8s-dns-sidecar" "rancher/k8s-dns-kube-dns" "rancher/machine" "rancher/mirrored-neuvector-scanner" "rancher/mirrored-banzaicloud-logging-operator" "rancher/mirrored-prom-prometheus" "rancher/istio-sidecar_injector" "rancher/istio-galley" "rancher/fluent-fluent-bit" "rancher/tiller" "rancher/mirrored-prom-node-exporter" "rancher/system-agent" "rancher/istio-citadel" "rancher/harvester" "rancher/eks-operator" "rancher/kiwigrid-k8s-sidecar" "rancher/mirrored-coreos-prometheus-config-reloader" "rancher/pipeline-jenkins-server" "rancher/k8s-dns-node-cache" "rancher/mirrored-longhornio-longhorn-ui" "rancher/cluster-proportional-autoscaler-amd64" "rancher/mirrored-calico-typha" "rancher/mirrored-k8s-dns-node-cache" "rancher/directxman12-k8s-prometheus-adapter-amd64" "rancher/mirrored-calico-operator" "rancher/mirrored-kiali-kiali" "rancher/mirrored-longhornio-csi-snapshotter" "rancher/mirrored-cloud-provider-vsphere-cpi-release-manager" "rancher/mirrored-longhornio-csi-attacher" "rancher/mirrored-longhornio-csi-resizer" "rancher/mirrored-longhornio-csi-provisioner" "rancher/os-docker" "rancher/mirrored-istio-install-cni" "rancher/mirrored-sonobuoy-sonobuoy" "rancher/mirrored-istio-pilot" "rancher/mirrored-minio-minio" "rancher/rio-dashboard" "rancher/fluentd-helper" "rancher/curl" "rancher/mirrored-cilium-cilium" "rancher/os-centosconsole" "rancher/kubernetes-external-dns" "rancher/longhorn-engine" "rancher/hardened-kube-proxy" "rancher/longhornio-longhorn-manager" "rancher/webhook-receiver" "rancher/mirrored-neuvector-enforcer" "rancher/kubectld" "rancher/mirrored-calico-ctl" "rancher/kubelet-pause" "rancher/lb-service-rancher" "rancher/mirrored-jettech-kube-webhook-certgen" "rancher/squareup-ghostunnel" "rancher/kubernetes-agent" "rancher/hardened-cni-plugins" "rancher/rio-autoscaler" "rancher/activator-2d008c4c36689d255523e5fa210c0bec" "rancher/swarmkit" "rancher/vm" "rancher/mirrored-sig-storage-snapshot-validation-webhook" "rancher/os-ubuntuconsole" "rancher/mirrored-sig-storage-snapshot-controller" "rancher/mirrored-openpolicyagent-gatekeeper" "rancher/banzaicloud-logging-operator" "rancher/externalip-webhook" "rancher/mirrored-cilium-operator-generic" "rancher/mirrored-sig-storage-livenessprobe" "rancher/os-headers" "rancher/cli" "rancher/calico-ctl" "rancher/mirrored-k8s-dns-dnsmasq-nanny" "rancher/mirrored-k8s-dns-sidecar" "rancher/k3d" "rancher/sonobuoy-sonobuoy" "rancher/mirrored-jaegertracing-all-in-one" "rancher/mirrored-k8s-dns-kube-dns" "rancher/longhornio-longhorn-ui" "rancher/mongodb-conf" "rancher/dind" "rancher/longhornio-csi-node-driver-registrar" "rancher/mirrored-sig-storage-csi-provisioner" "rancher/mirrored-sig-storage-csi-node-driver-registra" "rancher/mirrored-coreos-prometheus-operator" "rancher/mirrored-neuvector-controller" "rancher/mirrored-sig-storage-csi-attacher" "rancher/mirrored-k8scsi-livenessprobe" "rancher/mirrored-idealista-prom2teams" "rancher/opni-manager" "rancher/hardened-multus-cni" "rancher/mirrored-longhornio-longhorn-share-manager" "rancher/rancher-cleanup" "rancher/hardened-dns-node-cache" "rancher/socat-docker" "rancher/mirrored-k8scsi-csi-node-driver-registrar" "rancher/os-extras" "rancher/os-console" "rancher/harvester-network-controller" "rancher/vm-frontend" "rancher/os-debianconsole" "rancher/longhornio-csi-attacher" "rancher/os-base" ) #projects+=("andyshinn/dnsmasq" "mvance/unbound") #projects+=("luode0320/web-start") #projects+=("cloudnas/clouddrive2") #projects+=("portainer/portainer") #projects+=("hwdsl2/ipsec-vpn-server") #projects+=("neilpang/acme.sh") #projects+=("sdial/teleport") #projects+=("mvance/unbound") if [ ! -e /bin/docker-ls ]; then #wget https://vip.123pan.cn/1815238395/download/docker-ls/docker-ls-linux-amd64.zip -O /tmp/docker-ls.zip wget https://vip.123pan.cn/1815238395/download/docker-ls/docker-ls-windows-amd64.zip -O /tmp/docker-ls.zip unzip -d /bin/ /tmp/docker-ls.zip fi for project in "${projects[@]}"; do echo "开始新的project" sleep 0 echo $project project="$project" project1="docker/$project" tagList=$(docker-ls tags -r https://$harbor1 $project1 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') echo "tagList is $tagList" tagList2=$(docker-ls tags -r https://$harbor2 -u admin -p xxx $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') echo "tagList2 is $tagList2" for tag in $tagList; do echo "" echo "" if [ $(uname -m | grep x86_64 | wc -l ) -eq 1 ];then localArch="linux" fi if [ $(uname -m | grep aarch64 | wc -l ) -eq 1 ];then localArch="arm" fi if [ "$tag" == "latest" ]; then echo "发现latest TAG标签" continue else if [ $(echo $tagList2 | grep $tag | wc -l) -eq 1 ]; then echo "tag $tag 已存在目标harbor中，本次跳过" continue else echo "tag $tag 不存在目标harbor中，本次继续" fi fi imageName1="$harbor1/$project1:$tag" imageName2="$harbor2/$project:$tag" echo "" echo "开始进行$imageName1镜像的下载。" while true; do docker pull "$imageName1" if [ $? -eq 0 ]; then echo "下载$imageName1正常。" echo "开始等待" sleep 0 echo "等待结束，继续赶路！" break else echo "下载$imageName1异常。" echo "开始等待" sleep 0 break echo "等待结束，继续尝试..." fi done docker tag $imageName1 $imageName2 docker push $imageName2 # docker rmi $imageName1 $imageName2 done docker system prune -af done 另外，同步过程中对linux、windows、arm同时支持。当前仓库200GB+。
清理并部署harbor存储空间自动回收机制
周一，研发同事发来一张截图，大概意思是发布失败。分析jenkins日志，发现是镜像空间存储满了，导致无法将jenkins生成的容器镜像上传到harbor服务。删除镜像点击 “项目” -> “某个项目名称” -> “进入仓库” -> “选择要删除的制品”然后在操作栏下拉中选择删除。注意，这个时候并没有真正释放空间。点击“系统管理”->“垃圾清理”->“立即清理垃圾”。增加回收机制点击 “项目” -> “project” -> “Policy” -> “Add Rule”然后选择保留最新的10份tag然后点击DRY RUN，看看有哪些镜像会被删除。点击RUN NOW可以执行回收工作。增加定时执行后记为啥监控没有告警呢？查看了下夜莺监控，原来是没有开启主机监控项，配置了相关cpu、内存、磁盘的选项后，就可以收到告警了。
使用docker-ls查看容器仓库的镜像、标签等信息
docker-ls是啥？下载安装docker-lsif [ ! -e /bin/docker-ls ]; then wget https://vip.123pan.cn/1815238395/download/docker-ls/docker-ls-linux-amd64.zip -O /tmp/docker-ls-linux-amd64.zip unzip -d /bin/ /tmp/docker-ls-linux-amd64.zip fi 使用列出有多少个仓库docker-ls repositories -r https://docker.io docker-ls repositories -r https://harbor.sddts.cn --basic-auth -u admin -p xxx 列出某个仓库的标签docker-ls tags -r https://docker.io library/mysql
kubesphere是国内优秀的基于kubernetes开发的适合国内使用的k8s集群软件，部署简单，操作简单。为了进一步提高本地搭建测试效率，尝试将其安装部署中的各种容器放置到本地harbor仓库中。拿到kubesphere需要的容器镜像名称使用该链接，在Linuux上安装的离线安装部分，包含所有容器镜像内容[collapse status="false" title="容器镜像内容"] images: - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-apiserver:v1.23.15 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controller-manager:v1.23.15 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-proxy:v1.23.15 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-scheduler:v1.23.15 - registry.cn-beijing.aliyuncs.com/kubesphereio/pause:3.6 - registry.cn-beijing.aliyuncs.com/kubesphereio/coredns:1.8.6 - registry.cn-beijing.aliyuncs.com/kubesphereio/cni:v3.23.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controllers:v3.23.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/node:v3.23.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/pod2daemon-flexvol:v3.23.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/typha:v3.23.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/flannel:v0.12.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/provisioner-localpv:3.3.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/linux-utils:3.3.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/haproxy:2.3 - registry.cn-beijing.aliyuncs.com/kubesphereio/nfs-subdir-external-provisioner:v4.0.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/k8s-dns-node-cache:1.15.12 - registry.cn-beijing.aliyuncs.com/kubesphereio/ks-installer:v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/ks-apiserver:v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/ks-console:v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/ks-controller-manager:v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kubectl:v1.22.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kubectl:v1.21.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kubectl:v1.20.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kubefed:v0.8.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/tower:v0.2.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/minio:RELEASE.2019-08-07T01-59-21Z - registry.cn-beijing.aliyuncs.com/kubesphereio/mc:RELEASE.2019-08-07T23-14-43Z - registry.cn-beijing.aliyuncs.com/kubesphereio/snapshot-controller:v4.0.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/nginx-ingress-controller:v1.1.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/defaultbackend-amd64:1.4 - registry.cn-beijing.aliyuncs.com/kubesphereio/metrics-server:v0.4.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/redis:5.0.14-alpine - registry.cn-beijing.aliyuncs.com/kubesphereio/haproxy:2.0.25-alpine - registry.cn-beijing.aliyuncs.com/kubesphereio/alpine:3.14 - registry.cn-beijing.aliyuncs.com/kubesphereio/openldap:1.3.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/netshoot:v1.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/cloudcore:v1.13.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/iptables-manager:v1.13.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/edgeservice:v0.3.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/gatekeeper:v3.5.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/openpitrix-jobs:v3.3.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/devops-apiserver:ks-v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/devops-controller:ks-v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/devops-tools:ks-v3.4.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/ks-jenkins:v3.4.0-2.319.3-1 - registry.cn-beijing.aliyuncs.com/kubesphereio/inbound-agent:4.10-2 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-base:v3.2.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-nodejs:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-maven:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-maven:v3.2.1-jdk11 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-python:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.2-1.16 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.2-1.17 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.2-1.18 - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-base:v3.2.2-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-nodejs:v3.2.0-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-maven:v3.2.0-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-maven:v3.2.1-jdk11-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-python:v3.2.0-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.0-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.2-1.16-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.2-1.17-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/builder-go:v3.2.2-1.18-podman - registry.cn-beijing.aliyuncs.com/kubesphereio/s2ioperator:v3.2.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/s2irun:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/s2i-binary:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/tomcat85-java11-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/tomcat85-java11-runtime:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/tomcat85-java8-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/tomcat85-java8-runtime:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/java-11-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/java-8-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/java-8-runtime:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/java-11-runtime:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/nodejs-8-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/nodejs-6-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/nodejs-4-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/python-36-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/python-35-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/python-34-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/python-27-centos7:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/argocd:v2.3.3 - registry.cn-beijing.aliyuncs.com/kubesphereio/argocd-applicationset:v0.4.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/dex:v2.30.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/redis:6.2.6-alpine - registry.cn-beijing.aliyuncs.com/kubesphereio/configmap-reload:v0.7.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/prometheus:v2.39.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/prometheus-config-reloader:v0.55.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/prometheus-operator:v0.55.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-rbac-proxy:v0.11.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-state-metrics:v2.6.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/node-exporter:v1.3.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/alertmanager:v0.23.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/thanos:v0.31.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/grafana:8.3.3 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-rbac-proxy:v0.11.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/notification-manager-operator:v2.3.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/notification-manager:v2.3.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/notification-tenant-sidecar:v3.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/elasticsearch-curator:v5.7.6 - registry.cn-beijing.aliyuncs.com/kubesphereio/elasticsearch-oss:6.8.22 - registry.cn-beijing.aliyuncs.com/kubesphereio/opensearch:2.6.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/opensearch-dashboards:2.6.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/opensearch-curator:v0.0.5 - registry.cn-beijing.aliyuncs.com/kubesphereio/fluentbit-operator:v0.14.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/docker:19.03 - registry.cn-beijing.aliyuncs.com/kubesphereio/fluent-bit:v1.9.4 - registry.cn-beijing.aliyuncs.com/kubesphereio/log-sidecar-injector:v1.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/filebeat:6.7.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-events-operator:v0.6.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-events-exporter:v0.6.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-events-ruler:v0.6.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-auditing-operator:v0.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/kube-auditing-webhook:v0.2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/pilot:1.14.6 - registry.cn-beijing.aliyuncs.com/kubesphereio/proxyv2:1.14.6 - registry.cn-beijing.aliyuncs.com/kubesphereio/jaeger-operator:1.29 - registry.cn-beijing.aliyuncs.com/kubesphereio/jaeger-agent:1.29 - registry.cn-beijing.aliyuncs.com/kubesphereio/jaeger-collector:1.29 - registry.cn-beijing.aliyuncs.com/kubesphereio/jaeger-query:1.29 - registry.cn-beijing.aliyuncs.com/kubesphereio/jaeger-es-index-cleaner:1.29 - registry.cn-beijing.aliyuncs.com/kubesphereio/kiali-operator:v1.50.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/kiali:v1.50 - registry.cn-beijing.aliyuncs.com/kubesphereio/busybox:1.31.1 - registry.cn-beijing.aliyuncs.com/kubesphereio/nginx:1.14-alpine - registry.cn-beijing.aliyuncs.com/kubesphereio/wget:1.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/hello:plain-text - registry.cn-beijing.aliyuncs.com/kubesphereio/wordpress:4.8-apache - registry.cn-beijing.aliyuncs.com/kubesphereio/hpa-example:latest - registry.cn-beijing.aliyuncs.com/kubesphereio/fluentd:v1.4.2-2.0 - registry.cn-beijing.aliyuncs.com/kubesphereio/perl:latest - registry.cn-beijing.aliyuncs.com/kubesphereio/examples-bookinfo-productpage-v1:1.16.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/examples-bookinfo-reviews-v1:1.16.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/examples-bookinfo-reviews-v2:1.16.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/examples-bookinfo-details-v1:1.16.2 - registry.cn-beijing.aliyuncs.com/kubesphereio/examples-bookinfo-ratings-v1:1.16.3 - registry.cn-beijing.aliyuncs.com/kubesphereio/scope:1.13.0[/collapse]使用脚本将kubesphereio/scope等类似的镜像名称整理成bash shell脚本中的数组cat a.txt | awk -F\/ '{print $3}' | awk -F\: '{print "\"kubesphereio/"$1"\""}' | tr '\n' " ""kubesphereio/kube-apiserver" "kubesphereio/kube-controller-manager" "kubesphereio/kube-proxy" "kubesphereio/kube-scheduler" "kubesphereio/pause" "kubesphereio/coredns" "kubesphereio/cni" "kubesphereio/kube-controllers" "kubesphereio/node" "kubesphereio/pod2daemon-flexvol" "kubesphereio/typha" "kubesphereio/flannel" "kubesphereio/provisioner-localpv" "kubesphereio/linux-utils" "kubesphereio/haproxy" "kubesphereio/nfs-subdir-external-provisioner" "kubesphereio/k8s-dns-node-cache" "kubesphereio/ks-installer" "kubesphereio/ks-apiserver" "kubesphereio/ks-console" "kubesphereio/ks-controller-manager" "kubesphereio/kubectl" "kubesphereio/kubectl" "kubesphereio/kubectl" "kubesphereio/kubefed" "kubesphereio/tower" "kubesphereio/minio" "kubesphereio/mc" "kubesphereio/snapshot-controller" "kubesphereio/nginx-ingress-controller" "kubesphereio/defaultbackend-amd64" "kubesphereio/metrics-server" "kubesphereio/redis" "kubesphereio/haproxy" "kubesphereio/alpine" "kubesphereio/openldap" "kubesphereio/netshoot" "kubesphereio/cloudcore" "kubesphereio/iptables-manager" "kubesphereio/edgeservice" "kubesphereio/gatekeeper" "kubesphereio/openpitrix-jobs" "kubesphereio/devops-apiserver" "kubesphereio/devops-controller" "kubesphereio/devops-tools" "kubesphereio/ks-jenkins" "kubesphereio/inbound-agent" "kubesphereio/builder-base" "kubesphereio/builder-nodejs" "kubesphereio/builder-maven" "kubesphereio/builder-maven" "kubesphereio/builder-python" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-base" "kubesphereio/builder-nodejs" "kubesphereio/builder-maven" "kubesphereio/builder-maven" "kubesphereio/builder-python" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/s2ioperator" "kubesphereio/s2irun" "kubesphereio/s2i-binary" "kubesphereio/tomcat85-java11-centos7" "kubesphereio/tomcat85-java11-runtime" "kubesphereio/tomcat85-java8-centos7" "kubesphereio/tomcat85-java8-runtime" "kubesphereio/java-11-centos7" "kubesphereio/java-8-centos7" "kubesphereio/java-8-runtime" "kubesphereio/java-11-runtime" "kubesphereio/nodejs-8-centos7" "kubesphereio/nodejs-6-centos7" "kubesphereio/nodejs-4-centos7" "kubesphereio/python-36-centos7" "kubesphereio/python-35-centos7" "kubesphereio/python-34-centos7" "kubesphereio/python-27-centos7" "kubesphereio/argocd" "kubesphereio/argocd-applicationset" "kubesphereio/dex" "kubesphereio/redis" "kubesphereio/configmap-reload" "kubesphereio/prometheus" "kubesphereio/prometheus-config-reloader" "kubesphereio/prometheus-operator" "kubesphereio/kube-rbac-proxy" "kubesphereio/kube-state-metrics" "kubesphereio/node-exporter" "kubesphereio/alertmanager" "kubesphereio/thanos" "kubesphereio/grafana" "kubesphereio/kube-rbac-proxy" "kubesphereio/notification-manager-operator" "kubesphereio/notification-manager" "kubesphereio/notification-tenant-sidecar" "kubesphereio/elasticsearch-curator" "kubesphereio/elasticsearch-oss" "kubesphereio/opensearch" "kubesphereio/opensearch-dashboards" "kubesphereio/opensearch-curator" "kubesphereio/fluentbit-operator" "kubesphereio/docker" "kubesphereio/fluent-bit" "kubesphereio/log-sidecar-injector" "kubesphereio/filebeat" "kubesphereio/kube-events-operator" "kubesphereio/kube-events-exporter" "kubesphereio/kube-events-ruler" "kubesphereio/kube-auditing-operator" "kubesphereio/kube-auditing-webhook" "kubesphereio/pilot" "kubesphereio/proxyv2" "kubesphereio/jaeger-operator" "kubesphereio/jaeger-agent" "kubesphereio/jaeger-collector" "kubesphereio/jaeger-query" "kubesphereio/jaeger-es-index-cleaner" "kubesphereio/kiali-operator" "kubesphereio/kiali" "kubesphereio/busybox" "kubesphereio/nginx" "kubesphereio/wget" "kubesphereio/hello" "kubesphereio/wordpress" "kubesphereio/hpa-example" "kubesphereio/fluentd" "kubesphereio/perl" "kubesphereio/examples-bookinfo-productpage-v1" "kubesphereio/examples-bookinfo-reviews-v1" "kubesphereio/examples-bookinfo-reviews-v2" "kubesphereio/examples-bookinfo-details-v1" "kubesphereio/examples-bookinfo-ratings-v1" "kubesphereio/scope"准备额脚本内容#!/bin/bash harbor1="registry.cn-beijing.aliyuncs.com" harbor2="harbor.sddts.cn" docker login -u admin -p "123" harbor.sddts.cn projects=("kubesphereio/kube-apiserver" "kubesphereio/kube-controller-manager" "kubesphereio/kube-proxy" "kubesphereio/kube-scheduler" "kubesphereio/pause" "kubesphereio/coredns" "kubesphereio/cni" "kubesphereio/kube-controllers" "kubesphereio/node" "kubesphereio/pod2daemon-flexvol" "kubesphereio/typha" "kubesphereio/flannel" "kubesphereio/provisioner-localpv" "kubesphereio/linux-utils" "kubesphereio/haproxy" "kubesphereio/nfs-subdir-external-provisioner" "kubesphereio/k8s-dns-node-cache" "kubesphereio/ks-installer" "kubesphereio/ks-apiserver" "kubesphereio/ks-console" "kubesphereio/ks-controller-manager" "kubesphereio/kubectl" "kubesphereio/kubectl" "kubesphereio/kubectl" "kubesphereio/kubefed" "kubesphereio/tower" "kubesphereio/minio" "kubesphereio/mc" "kubesphereio/snapshot-controller" "kubesphereio/nginx-ingress-controller" "kubesphereio/defaultbackend-amd64" "kubesphereio/metrics-server" "kubesphereio/redis" "kubesphereio/haproxy" "kubesphereio/alpine" "kubesphereio/openldap" "kubesphereio/netshoot" "kubesphereio/cloudcore" "kubesphereio/iptables-manager" "kubesphereio/edgeservice" "kubesphereio/gatekeeper" "kubesphereio/openpitrix-jobs" "kubesphereio/devops-apiserver" "kubesphereio/devops-controller" "kubesphereio/devops-tools" "kubesphereio/ks-jenkins" "kubesphereio/inbound-agent" "kubesphereio/builder-base" "kubesphereio/builder-nodejs" "kubesphereio/builder-maven" "kubesphereio/builder-maven" "kubesphereio/builder-python" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-base" "kubesphereio/builder-nodejs" "kubesphereio/builder-maven" "kubesphereio/builder-maven" "kubesphereio/builder-python" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/builder-go" "kubesphereio/s2ioperator" "kubesphereio/s2irun" "kubesphereio/s2i-binary" "kubesphereio/tomcat85-java11-centos7" "kubesphereio/tomcat85-java11-runtime" "kubesphereio/tomcat85-java8-centos7" "kubesphereio/tomcat85-java8-runtime" "kubesphereio/java-11-centos7" "kubesphereio/java-8-centos7" "kubesphereio/java-8-runtime" "kubesphereio/java-11-runtime" "kubesphereio/nodejs-8-centos7" "kubesphereio/nodejs-6-centos7" "kubesphereio/nodejs-4-centos7" "kubesphereio/python-36-centos7" "kubesphereio/python-35-centos7" "kubesphereio/python-34-centos7" "kubesphereio/python-27-centos7" "kubesphereio/argocd" "kubesphereio/argocd-applicationset" "kubesphereio/dex" "kubesphereio/redis" "kubesphereio/configmap-reload" "kubesphereio/prometheus" "kubesphereio/prometheus-config-reloader" "kubesphereio/prometheus-operator" "kubesphereio/kube-rbac-proxy" "kubesphereio/kube-state-metrics" "kubesphereio/node-exporter" "kubesphereio/alertmanager" "kubesphereio/thanos" "kubesphereio/grafana" "kubesphereio/kube-rbac-proxy" "kubesphereio/notification-manager-operator" "kubesphereio/notification-manager" "kubesphereio/notification-tenant-sidecar" "kubesphereio/elasticsearch-curator" "kubesphereio/elasticsearch-oss" "kubesphereio/opensearch" "kubesphereio/opensearch-dashboards" "kubesphereio/opensearch-curator" "kubesphereio/fluentbit-operator" "kubesphereio/docker" "kubesphereio/fluent-bit" "kubesphereio/log-sidecar-injector" "kubesphereio/filebeat" "kubesphereio/kube-events-operator" "kubesphereio/kube-events-exporter" "kubesphereio/kube-events-ruler" "kubesphereio/kube-auditing-operator" "kubesphereio/kube-auditing-webhook" "kubesphereio/pilot" "kubesphereio/proxyv2" "kubesphereio/jaeger-operator" "kubesphereio/jaeger-agent" "kubesphereio/jaeger-collector" "kubesphereio/jaeger-query" "kubesphereio/jaeger-es-index-cleaner" "kubesphereio/kiali-operator" "kubesphereio/kiali" "kubesphereio/busybox" "kubesphereio/nginx" "kubesphereio/wget" "kubesphereio/hello" "kubesphereio/wordpress" "kubesphereio/hpa-example" "kubesphereio/fluentd" "kubesphereio/perl" "kubesphereio/examples-bookinfo-productpage-v1" "kubesphereio/examples-bookinfo-reviews-v1" "kubesphereio/examples-bookinfo-reviews-v2" "kubesphereio/examples-bookinfo-details-v1" "kubesphereio/examples-bookinfo-ratings-v1" "kubesphereio/scope") if [ ! -e /bin/docker-ls ]; then wget https://vip.123pan.cn/1815238395/download/docker-ls/docker-ls-linux-amd64.zip -O /tmp/docker-ls-linux-amd64.zip unzip -d /bin/ /tmp/docker-ls-linux-amd64.zip fi for project in "${projects[@]}"; do echo "" echo "" echo "开始新的project" set -x echo $project tagList=$(docker-ls tags -r https://registry.cn-beijing.aliyuncs.com $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') echo "tagList is $tagList" tagList2=$(docker-ls tags -r https://$harbor2 -u admin -p Lab@1234 $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') echo "tagList2 is $tagList2" for tag in $tagList; do if [ "$tag" == "latest" ]; then echo "发现latest TAG标签" else if [ $(echo $tagList2 | grep $tag | wc -l) -eq 1 ]; then echo "tag $tag 已存在目标harbor中，本次跳过" continue else echo "tag $tag 不存在目标harbor中，本次继续" fi fi imageName="$project:$tag" imageName1="$harbor1/$imageName" echo "" echo "开始进行$imageName1镜像的下载。" while true; do docker pull "$imageName1" if [ $? -eq 0 ]; then echo "下载$imageName1正常。" echo "开始等待1分钟" sleep 60 echo "等待结束，继续赶路！" break else echo "下载$imageName1异常。" echo "开始等待3600秒" sleep 3600 echo "等待1小时，继续尝试..." fi done imageName2="$harbor2/$imageName" docker tag $imageName1 $imageName2 docker push $imageName2 docker rmi $imageName1 $imageName2 done done
#!/bin/bash harbor2="harbor.sddts.cn" dockerhubTokens=("zzlyzq:111" "zzlyzq1:111") docker login -u zzlyzq -p "111" docker.io docker login -u admin -p "111" harbor.sddts.cn #projects=("library/mysql" "library/alpine") projects=("library/mysql" "library/alpine" "library/centos" "library/debian" "library/ubuntu" "library/python" "library/redis" "library/nginx" "library/busybox" "library/postgres" "library/node" "library/memcached" "library/httpd" "library/mongo" "library/rabbitmq" "library/mariadb" "library/docker" "library/hello-world" "library/openjdk" "library/golang" "library/registry" "library/wordpress" "library/php" "library/consul" "library/influxdb" "library/haproxy" "library/tomcat" "library/maven" "library/bash" "library/ghost" "library/kong" "library/zookeeper" "jenkins/jenkins" "library/mediawiki" "library/django" "library/gcc" "chaitin/safeline-tengine" "chaitin/safeline-mgt-api" "chaitin/safeline-detector" "chaitin/safeline-mario" "jumpserver/lion" "jumpserver/koko" "jumpserver/guacamole" "jumpserver/core" "jumpserver/jms_all" "jumpserver/web" "jumpserver/redis" "jumpserver/nginx" "jumpserver/core" "jumpserver/mysql" "jumpserver/magnus" "jumpserver/mariadb" "jumpserver/luna" "jumpserver/guacamole" "jumpserver/lina" "jumpserver/chen" "jumpserver/kael" "jumpserver/guacd" "jumpserver/python" "jumpserver/jms_web") if [ ! -e /bin/docker-ls ]; then wget https://vip.123pan.cn/1815238395/download/docker-ls/docker-ls-linux-amd64.zip -O /tmp/docker-ls-linux-amd64.zip unzip -d /bin/ /tmp/docker-ls-linux-amd64.zip fi for project in "${projects[@]}"; do echo "开始新的project" echo $project tagList=$(docker-ls tags $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') echo "tagList is $tagList" tagList2=$(docker-ls tags -r https://$harbor2 -u admin -p 111 $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') echo "tagList2 is $tagList2" for tag in $tagList; do if [ "$tag" == "latest" ]; then echo "发现latest TAG标签" else if [ $(echo $tagList2 | grep $tag | wc -l) -eq 1 ]; then echo "tag $tag 已存在目标harbor中，本次跳过" continue else echo "tag $tag 不存在目标harbor中，本次继续" fi fi imageName="$project:$tag" imageName1="docker.io/$imageName" for token in "${dockerhubTokens[@]}"; do IFS=":" read -ra values <<<"$token" token_id="${values[0]}" echo $token_id echo $token_key token_key="${values[1]}" docker login -u $token_id -p $token_key https://docker.io docker pull "$imageName1" if [ $? -eq 0 ]; then echo "下载$imageName1正常。" break else echo "下载$imageName1异常。" fi done imageName2="$harbor2/$imageName" docker tag $imageName1 $imageName2 docker push $imageName2 docker rmi $imageName1 $imageName2 done done
#!/bin/bash harbor2="harbor.sddts.cn" harbor1List=("docker.io" "dockerproxy.com" "docker.nju.edu.cn") docker login -u zzlyzq -p "111" docker.io docker login -u admin -p "123" harbor.sddts.cn #projects=("library/mysql" "library/alpine") projects=("library/mysql" "library/alpine" "library/centos" "library/debian" "library/ubuntu" "library/python" "library/redis" "library/nginx" "library/busybox" "library/postgres" "library/node" "library/memcached" "library/httpd" "library/mongo" "library/rabbitmq" "library/mariadb" "library/docker" "library/hello-world" "library/openjdk" "library/golang" "library/registry" "library/wordpress" "library/php" "library/consul" "library/influxdb" "library/haproxy" "library/tomcat" "library/maven" "library/bash" "library/ghost" "library/kong" "library/zookeeper" "jenkins/jenkins" "library/mediawiki" "library/django" "library/gcc" "chaitin/safeline-tengine" "chaitin/safeline-mgt-api" "chaitin/safeline-detector" "chaitin/safeline-mario" "jumpserver/lion" "jumpserver/koko" "jumpserver/guacamole" "jumpserver/core" "jumpserver/jms_all" "jumpserver/web" "jumpserver/redis" "jumpserver/nginx" "jumpserver/core" "jumpserver/mysql" "jumpserver/magnus" "jumpserver/mariadb" "jumpserver/luna" "jumpserver/guacamole" "jumpserver/lina" "jumpserver/chen" "jumpserver/kael" "jumpserver/guacd" "jumpserver/python" "jumpserver/jms_web") if [ ! -e /bin/docker-ls ]; then wget https://vip.123pan.cn/1815238395/download/docker-ls/docker-ls-linux-amd64.zip -O /tmp/docker-ls-linux-amd64.zip unzip -d /bin/ /tmp/docker-ls-linux-amd64.zip fi for project in "${projects[@]}"; do echo $project tagList=$(docker-ls tags -r https://docker.io -u zzlyzq -p "123" $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') tagList2=$(docker-ls tags -r https://$harbor2 -u admin -p 123 $project 2>/dev/null | grep '\- ' | tr -d '"' | awk '{print $2}') for tag in $tagList; do if [ "$tag" = "latest" ]; then continue else #ifExistsIn=`echo $tagList2 | grep $tag | wc -l` if [ $(echo $tagList2 | grep $tag | wc -l) -eq 1 ]; then echo "tag $tag 已存在目标harbor中，本次跳过" continue else echo "tag $tag 不存在目标harbor中，本次继续" fi fi for harbor1 in "${harbor1List[@]}"; do imageName="$project:$tag" imageName1="$harbor1/$imageName" echo "开始下载$imageName1" docker pull "$imageName1" if [ $? -eq 0 ]; then echo "下载$imageName1正常" break else echo "下载$imageName1异常" fi done imageName2="$harbor2/$imageName" docker tag $imageName1 $imageName2 docker push $imageName2 docker rmi $imageName1 $imageName2 done done
docker-compose文件version: '3' services: registry: image: registry:2 ports: - 172.31.20.2:5000:5000 volumes: - ./data:/var/lib/registry networks: mynetwork: ipv4_address: 172.31.20.2 networks: mynetwork: ipam: config: - subnet: 172.31.20.0/24 客户端文件{ "registry-mirrors": ["http://localhost:5000"], "insecure-registries": ["localhost:5000"] }