06
2023
11
22:48:41

群晖Docker导入镜像 解决镜像因为网络下载失败问题



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

其实群晖的Docker镜像和普通Docker命令操作基本上是一样的,底层也是使用containerd。当我们去映像下载镜像失败,提示网络超时时,可以借助下面的方法解决。前提是有一台服务器,也可以替换国内镜像

  • 使用国内镜像导入

  • 用海外服务器的镜像在群晖Docker中导入


我们可以先用海外服务器下载海外的镜像,然后push到国内镜像站

我们海外服务器安装Docker后,直接pull镜像 (我这里以gitlab作为演示)

[root@VM-8-10-centos ~]# docker pull gitlab/gitlab-ce
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
eaead16dc43b: Pull complete 
10a81fed2873: Pull complete 
a1e59b88d6f2: Pull complete 
d5b24f9b6012: Pull complete 
c604c3da3b6e: Pull complete 
1e64f6b8d017: Pull complete 
c2b7e253cbda: Pull complete 
2e2451eb729b: Pull complete 
Digest: sha256:29828378e9bf0152a8f0eeb4f672a03c5b2c18a57b4a32e56b53c79b59b8e3d6
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest
[root@VM-8-10-centos ~]#

1668578101117.png

上传到国内镜像方式

  • 上传到国内镜像服务器

  • 这里以为阿里云镜像站为主

    需要在创建一个镜像仓库
    1668578391819.png
    我这里命名gitlab

  • 仓库名称: 可以随便起

  • 仓库类型: 需要设置公开,其它人就可以使用你本地镜像

  • 1668578467965.png
    代码源使用本地1668578538877.png
    接下来需要在我们的海外服务器登陆镜像仓库

    pull下载镜像是所有人都有权限,但是上传肯定是只有管理员有权限,就需要登陆了

    1668578609063.png
    服务器执行下面命令

    #先docker login登陆
    [root@VM-8-10-centos ~]# docker login --username=cyh60441314 registry.cn-beijing.aliyuncs.com
    Password: 
    WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
    Configure a credential helper to remove this warning. See
    https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    
    Login Succeeded
    #这里代表登陆成功

    修改镜像名称

    [root@VM-8-10-centos ~]# docker tag gitlab/gitlab-ce:latest registry.cn-beijing.aliyuncs.com/abcdocker/gitlab:2022-11-16
    
    #latest为版本号,latest为最新版本,也可以pull其它版本
    #2022-11-16为我们镜像仓库的gitlab版本号,同样也可以随便写

    上传镜像

    [root@VM-8-10-centos ~]# docker push registry.cn-beijing.aliyuncs.com/abcdocker/gitlab:2022-11-16
    
    #需要push我们打好标签的版本号

    导出导入镜像

    不管是下载国内的镜像,还是国外的镜像,都是需要Docker工具。

    # 可以安装window Docker客户端,或者mac端。或者服务器
    docker pull registry.cn-beijing.aliyuncs.com/abcdocker/gitlab:2022-11-16
    
    # docker save registry.cn-beijing.aliyuncs.com/abcdocker/gitlab:2022-11-16 >gitlab_2022-11-16.tar

    最终我们上传到服务器上,展示效果如下
    1668652870442.png

    通过文件共享的方式,将上面打包的镜像导出下载。

    导入镜像

    #ssh到我们的存储路径下
    
    root@frps:/volume1# cd /volume1/homes/frp/Drive/
    
    #使用docker load -i 文件.tar 导入镜像
    root@frps:/volume1/homes/frp/Drive# docker load -i gitlab_2022-11-16.tar 
    f4462d5b2da2: Loading layer  75.16MB/75.16MB
    d749c499c133: Loading layer   67.7MB/67.7MB
    c5aa731f027d: Loading layer  798.7kB/798.7kB
    0542cb5a15dc: Loading layer  2.048kB/2.048kB
    e57b1c62d561: Loading layer  2.048kB/2.048kB
    b62a384edabd: Loading layer  2.048kB/2.048kB
    08c764a54a40: Loading layer  22.02kB/22.02kB
    f92fd4176edb: Loading layer  2.685GB/2.685GB
    Loaded image: gitlab/gitlab-ce:latest
    #此处可以看到镜像名gitlab/gitlab-ce:latest
    
    root@frp:/volume1/homes/frp/Drive# docker images
    REPOSITORY                            TAG           IMAGE ID       CREATED         SIZE
    gitlab/gitlab-ce                      latest        d3ed3f0e1905   4 days ago      2.75GB
    fireflyiii/core                       latest        3d4c3d6e7219   2 months ago    530MB
    neosmemo/memos                        latest        6c2458bf7994   2 months ago    22.2MB
    xhofe/alist                           latest        e1839491349e   3 months ago    39.7MB
    diygod/rsshub                         latest        0eb4ced82e6f   6 months ago    227MB
    frps9/tools                           utils         a3275350b9c5   8 months ago    539MB
    zx5253/webdav-aliyundriver            latest        baeeb12ff267   9 months ago    511MB
    bash                                  latest        53e520fda182   9 months ago    13MB
    guyskk/rssant                         latest        e70fd794237a   10 months ago   1.61GB
    pryorda/vmware_exporter               latest        17342cf77161   13 months ago   111MB
    iyuucn/iyuuplus                       latest        6e59662bbf01   14 months ago   57.6MB
    alhazmy13/telegraf-influxdb-grafana   latest        90c83767ee15   17 months ago   1GB
    frps9/tools                           SynologyNAS   90c83767ee15   17 months ago   1GB
    synology/docviewer                    1.3.0.0125    05f0258f226c   2 years ago     2.2GB
    synology/docviewer                    latest        05f0258f226c   2 years ago     2.2GB
    oldiy/frpc                            latest        846bd5c0d1ef   3 years ago     14.9MB
    ashdev/docker-toolbox                 latest        e9e5f98aa6b5   6 years ago     374MB
    #这里也可以看到镜像名gitlab/gitlab-ce:latest

    如果我们使用registry.cn-beijing.aliyuncs.com/abcdocker/gitlab:2022-11-16 只需要通过下面的命令改个tag即可

    docker tag registry.cn-beijing.aliyuncs.com/abcdocker/gitlab:2022-11-16 gitlab/gitlab-ce:latest

    此时我们的Docker容器已经有了镜像了,但是前台发现并没有看到。 我们需要重新搜索下载一遍镜像,就可以实现秒下载了。
    效果图1668653439825.png


本文链接:https://hqyman.cn/post/4495.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: