#!/bin/bash # Fscan 测试镜像拉取脚本 # 排除 IMAP、POP3、Modbus 相关镜像 echo "=== Fscan 测试镜像拉取开始 ===" echo "排除服务: IMAP, POP3, Modbus" echo "" # 基础镜像列表 images=( # 数据库服务 "mysql:latest" "postgres:latest" "mongo:latest" "redis:5.0.1" "mcr.microsoft.com/mssql/server:2022-latest" "neo4j:4.4" "memcached:latest" "cassandra:3.11" # Web服务 "tomcat:9.0-jdk8" "container-registry.oracle.com/middleware/weblogic:12.2.1.4-dev" # 搜索引擎 "docker.elastic.co/elasticsearch/elasticsearch:7.9.3" # 消息队列 "rabbitmq:3-management" "rmohr/activemq:5.15.9" "bitnami/kafka:latest" # 监控系统 "zabbix/zabbix-server-mysql:ubuntu-6.0.23" "zabbix/zabbix-web-nginx-mysql:ubuntu-6.0.23" # 目录服务 "osixia/openldap:1.5.0" # 网络服务 "bogem/ftp" "ubuntu:latest" # SSH, SMTP, SNMP, Rsync, VNC, Telnet "ubuntu:20.04" # SSH, SMTP, SNMP, Rsync, VNC, Telnet "busybox:latest" # Telnet ) # 记录成功和失败的镜像 success_count=0 failed_images=() total_images=${#images[@]} echo "需要拉取 $total_images 个镜像" echo "" # 拉取镜像函数 pull_image() { local image=$1 local current=$2 local total=$3 echo "[$current/$total] 拉取镜像: $image" # 设置超时和重试 local max_retries=3 local retry=0 while [ $retry -lt $max_retries ]; do if timeout 300 docker pull "$image"; then echo "✓ 成功: $image" ((success_count++)) return 0 else ((retry++)) if [ $retry -lt $max_retries ]; then echo "⚠ 重试 $retry/$max_retries: $image" sleep 5 fi fi done echo "✗ 失败: $image (超时或网络错误)" failed_images+=("$image") return 1 } # 开始拉取 start_time=$(date +%s) for i in "${!images[@]}"; do current=$((i + 1)) pull_image "${images[$i]}" "$current" "$total_images" echo "" done # 统计结果 end_time=$(date +%s) duration=$((end_time - start_time)) failed_count=${#failed_images[@]} echo "=== 拉取完成 ===" echo "总镜像数: $total_images" echo "成功: $success_count" echo "失败: $failed_count" echo "用时: ${duration}s" echo "" # 显示失败的镜像 if [ $failed_count -gt 0 ]; then echo "失败的镜像:" for image in "${failed_images[@]}"; do echo " - $image" done echo "" echo "可以重新运行脚本来重试失败的镜像" fi # 检查 Docker 存储空间 echo "=== Docker 存储使用情况 ===" docker system df echo "" echo "脚本执行完成!"