51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

本地拉取Docker镜像打包导入远程服务器

起因是因为使用远程服务器拉取镜像时,由于网络问题一直拉不成功,使用国内镜像由于更新不及时,国内镜像没有最新的 docker 镜像。最后使用本地的计算机,通过代理下载最新的镜像后打包成 tar, 然后上传到远程服务器进行导入。

博主博客 {#博主博客}

起因 {#起因}

使用远程服务器拉代码会报一下错误。

  
  
   
   
* 
                          01
                        

   
   
* 
                          02
                        

  
  

                    
                      [root@nukix RSSHub]# docker pull diygod/rsshub:chromium-bundled-2024-10-14
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

                    </code>
                  </pre>



 
一、拉取镜像 {#一、拉取镜像}
----------------


 
可以先进入 https://hub.docker.com/ 查找需要下载的镜像, 然后选择对应的架构进行拉取。

 
![RSSHub在Docker上的截图.png](http://static.51tbox.com/static/2024-12-12/col/6a3372eb75bc24c2879d173f1445564b/a83225c0e5824a9d8a6768fedeb3592a.png.jpg)

 
使用命令 ` docker pull 镜像名:版本@摘要值 ` 进行拉取,这里要注意根据需要下载的架构选择对应镜像的摘要值进行下载,不加摘要值会下载当前系统的镜像,可能不适合远程服务器架构。

 
`````prism language-ssh
                    
                      nukix@MacBook-Pro ~ % docker pull diygod/rsshub:chromium-bundled-2024-10-14@sha256:ff4a5aa02f3df2a0b20ad1e5e9dfffef08aa7c7f1b5665af5db077d10ca79db6
docker.io/diygod/rsshub@sha256:ff4a5aa02f3df2a0b20ad1e5e9dfffef08aa7c7f1b5665af5db077d10ca79db6: Pulling from diygod/rsshub
302e3ee49805: Pull complete
f09acf3eb611: Pull complete
41ec6ae33593: Pull complete
e1068effa50f: Pull complete
0255ce87cb40: Pull complete
ec33c6e82ec0: Pull complete
c848b143ce12: Pull complete
256fcb80beb5: Pull complete
4f4fb700ef54: Pull complete
d18f8029719b: Pull complete
Digest: sha256:ff4a5aa02f3df2a0b20ad1e5e9dfffef08aa7c7f1b5665af5db077d10ca79db6
Status: Downloaded newer image for diygod/rsshub@sha256:ff4a5aa02f3df2a0b20ad1e5e9dfffef08aa7c7f1b5665af5db077d10ca79db6
docker.io/diygod/rsshub:chromium-bundled-2024-10-14@sha256:ff4a5aa02f3df2a0b20ad1e5e9dfffef08aa7c7f1b5665af5db077d10ca79db6

nukix@MacBook-Pro \~ % docker images
REPOSITORY  TAG IMAGE ID CREATED SIZE
diygod/rsshub \<none\>  c1f27ad1ee6f 6 hours ago 1.36GB


                    </code>
                  </pre>



 
拉取完成后使用 ` docker images ` 命令可以查看下载后的镜像。

 
二、打包镜像 {#二、打包镜像}
----------------


 
                        
                          nukix@MacBook-Pro ~ % docker save c1f27ad1ee6f > ./rsshub.tar

                        </code>
                      </pre>



     
    使用 ` docker save 镜像ID > 路径 ` 把镜像打包到指定路径下。

     
    三、加载镜像 {#三、加载镜像}
    ----------------


     
    ````prism language-ssh
                        
                          [root@nukix RSSHub]# docker load < rsshub.tar
    8d853c8add5d: Loading layer [==================================================>]  77.83MB/77.83MB
    998b55b01293: Loading layer [==================================================>]   21.5kB/21.5kB
    4ff4e33e2042: Loading layer [==================================================>]  135.5MB/135.5MB
    d741aa1acde2: Loading layer [==================================================>]   7.21MB/7.21MB
    1129945e3488: Loading layer [==================================================>]  3.584kB/3.584kB
    356ddc962e44: Loading layer [==================================================>]  1.536kB/1.536kB
    98b50a20aa5f: Loading layer [==================================================>]  128.7MB/128.7MB
    89f80732f40f: Loading layer [==================================================>]  565.8MB/565.8MB
    5f70bf18a086: Loading layer [==================================================>]  1.024kB/1.024kB
    6de60b6f87bc: Loading layer [==================================================>]  503.1MB/503.1MB
    Loaded image ID: sha256:c1f27ad1ee6f9ea8f02b0b0dce5d3077912685517987eef68a8dfd8a63248c9a

    \[root@nukix RSSHub\]# docker images
    REPOSITORY                   TAG       IMAGE ID       CREATED         SIZE
    \<none\>                       \<none\>    c1f27ad1ee6f   6 hours ago     1.36GB


                        </code>
                      </pre>



     
    把打包后的镜像传送到服务器端, 然后使用命令 ` docker load < 路径 ` 加载打包后的镜像。加载完成后查看镜像, 可以看出 ` TAG ` 为 ` <none> ` 。

     
    四、修改标签 {#四、修改标签}
    ----------------


     
    ```prism language-ssh
                        
                          [root@nukix RSSHub]# docker tag c1f27ad1ee6f diygod/rsshub:chromium-bundled-2024-10-14

    \[root@nukix RSSHub\]# docker images
    REPOSITORY                   TAG                           IMAGE ID       CREATED         SIZE
    diygod/rsshub                chromium-bundled-2024-10-14   c1f27ad1ee6f   6 hours ago     1.36GB


                        </code>
                      </pre>



     
    使用 ` docker tag 镜像ID 镜像名:版本 ` 把标签修改为执行的名称。

     
    ![RSSHub Docker Compose Tag 截图.png](http://static.51tbox.com/static/2024-12-12/col/6a3372eb75bc24c2879d173f1445564b/d21d975bc77a4bb7aab626891db25d78.png.jpg)

     
    如果使用 docker compose, 需要注意 TAG 对应上面设置的名称。


    ```


    ````




`````

赞(3)
未经允许不得转载:工具盒子 » 本地拉取Docker镜像打包导入远程服务器