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不下来的问题。
链接