上一主题 下一主题
ScriptCat,新一代的脚本管理器脚本站,与全世界分享你的用户脚本油猴脚本开发指南教程目录
返回列表 发新帖
楼主: 朱焱伟 - 

dget直接下载DockerHub镜像包

[复制链接]
  • TA的每日心情

    2025-2-10 23:00
  • 签到天数: 316 天

    [LV.8]以坛为家I

    14

    主题

    64

    回帖

    661

    积分

    荣誉开发者

    积分
    661

    荣誉开发者生态建设者

    发表于 2025-2-10 22:55:34 | 显示全部楼层 | 阅读模式

    dget直接下载DockerHub镜像包

    早先时候,dockerhub各镜像站被封了,我没有说话;后来,greasyfork被封了,我没有说话;再后来。。脚本猫没封,哈哈,推荐大家使用脚本猫。

    开个玩笑,不过dockerhub镜像站被封有时确实不方便。虽可以修改/etc/docker/daemon.json里的registry-mirrors,但随着镜像站一个个倒下,事情变得麻烦起来。如果不想使用个人账户阿里云的加速地址,也懒得给每台服务器设置代理,或许还是导出docker镜像,之后到处传文件比较方便。

    dget这个工具可以用于直接从docker hub中下载镜像包,先在自己可以方便上网的Win电脑上下好镜像。

    clash 7890

    首先,需要自己的Windows电脑方便上网:如果使用clash,其默认端口为7890,打开后,我们的目的是需要Powershell终端里也能方便上网。

    notepad $(echo $PROFILE)会打开Microsoft.PowerShell_profile.ps1,我们可以设置一些常用命令:

    function clash-set-proxy {
        $env:http_proxy = "http://127.0.0.1:7890"
        $env:https_proxy = "http://127.0.0.1:7890"
        [System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://127.0.0.1:7890")
        Write-Host "Proxy enabled: http://127.0.0.1:7890" -ForegroundColor Green
    }
    
    function clash-unproxy {
        $env:http_proxy = $null
        $env:https_proxy = $null
        [System.Net.WebRequest]::DefaultWebProxy = $null
        Write-Host "Proxy disabled" -ForegroundColor Yellow
    }
    
    function clash-check-proxy {
        if ($env:http_proxy -or $env:https_proxy) {
            Write-Host "Current proxy settings:" -ForegroundColor Cyan
            Write-Host "HTTP Proxy: $env:http_proxy"
            Write-Host "HTTPS Proxy: $env:https_proxy"
        } else {
            Write-Host "No proxy is currently set." -ForegroundColor Cyan
        }
    }

    保存后,打开新的Powershell终端,那么新加的几个命令就生效了。

    curl.exe -vv http://www.google.com

    clash-set-proxy,再curl.exe -vv http://www.google.com,确认上网环境可以。(最后结束后可以clash-unproxy来关掉)

    dget.exe

    然后可以下载dget.exe,然后放到C:\Users\当前用户目录下,这样方便下次打开powershell终端可以使用dget.exe

    $url = "https://gitee.com/extrame/dget/raw/master/bin/windows_amd64/dget.exe"
    $outputPath = "dget.exe"
    Invoke-WebRequest -Uri $url -OutFile $outputPath
    # 获取当前用户的目录路径
    $userProfilePath = $env:USERPROFILE
    
    # 定义目标路径(当前用户目录下的 dget.exe)
    $destinationPath = Join-Path -Path $userProfilePath -ChildPath "dget.exe"
    
    # 检查系统中是否已存在 dget.exe
    if (-not (Test-Path -Path $destinationPath)) {
        # 如果不存在,则将下载的文件移动到当前用户目录
        Move-Item -Path $outputPath -Destination $destinationPath -Force
        Write-Host "dget.exe 已复制到: $destinationPath"
    } else {
        # 如果已存在,则提示
        Write-Host "dget.exe 已存在于: $destinationPath"
        # 删除临时下载的文件
        Remove-Item -Path $outputPath -Force
    }

    用dget来下dockerhub上的镜像

    van-nav镜像为例,来在windows下尝试下载镜像:

    .\dget.exe mereith/van-nav:latest

    可以得到./tmp_mereith/van-nav_latest-img.tar.gz,然后将其通过ftp上传到linux下,linux下就去load这个镜像

    sudo docker load -i van-nav_latest-img.tar.gz
    mkdir -p /usr/local/selfhosted/file/van-nav
    sudo docker run -d --name tools --restart always -p 6412:6412 -v /usr/local/selfhosted/file/van-nav:/app/data mereith/van-nav:latest
    # 浏览器访问 http://192.168.XXX.XXX:6412/

    这样,就成功部署了一个简易的单文件的网页导航站,可以通过6412端口访问网页,通过dget避免了pull不下来的问题。

    链接

    当冥想的日子飞逝,喧嚣的日子把我们唤去,且在此地留下些微的痕迹

    发表回复

    本版积分规则

    快速回复 返回顶部 返回列表