欢迎光临
我们一直在努力

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

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

    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#查看到我们刚载入的镜像

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。