温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

通过把docker镜像保存为文件载入到别的服务器

发布时间:2020-07-04 03:27:58 来源:网络 阅读:558 作者:知行知行 栏目:系统运维

       在我们的工作环境中,一般镜像通过上传到镜像仓库中(本地或者公共仓库),用到时下载到服务器上即可。如果服务器不能上网,又没有私有仓库,我们就需要将镜像保存为文件上传到服务器上,载入镜像即可使用。

    1、保存镜像为文件

    命令:

#docker save --help

Usage:  docker save [OPTIONS] IMAGE [IMAGE...]

Save one or more images to a tar archive (streamed to STDOUT by default)

Options:

  -o, --output string   Write to a file, instead of STDOUT

例:

docker images|grep centos#查看需要保存的镜像

centos                                           latest              0f3e07c0138f        2 months ago        220MB

docker save -o centos.tar centos#把镜像保存为centos.tar文件,ls可以查看到该文件。

    2、文件载入镜像

    命令:

docker load --help

Usage:  docker load [OPTIONS]

Load an image from a tar archive or STDIN

Options:

  -i, --input string   Read from tar archive file, instead of STDIN

  -q, --quiet          Suppress the load output

例:把刚才我们保存的文件上传到我们需要的服务器上

docker load -i  centos.tar 

或者:

docker load <centos.tar

docker images#查看到我们刚载入的镜像


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI