在咱們的工做環境中,通常鏡像經過上傳到鏡像倉庫中(本地或者公共倉庫),用到時下載到服務器上便可。若是服務器不能上網,又沒有私有倉庫,咱們就須要將鏡像保存爲文件上傳到服務器上,載入鏡像便可使用。docker
一、保存鏡像爲文件
centos
命令:
服務器
#docker save --helpide
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
ui
Save one or more images to a tar archive (streamed to STDOUT by default)
spa
Options:
input
-o, --output string Write to a file, instead of STDOUT文件上傳
例:string
docker images|grep centos#查看須要保存的鏡像it
centos latest 0f3e07c0138f 2 months ago 220MB
docker save -o centos.tar centos#把鏡像保存爲centos.tar文件,ls能夠查看到該文件。
二、文件載入鏡像
命令:
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#查看到咱們剛載入的鏡像