概述
一 保存镜像
[root@localhost mydocker]# 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
-o 指定保存镜像的位置
保存镜像时候要用镜像名称:标签,不要用镜像ID,否则导入默认镜像名称和版本为null。
保存镜像redis到 /mydocker/images/redis.tar
[root@localhost mydocker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest ccee4cdf984f 8 days ago 105MB
[root@localhost mydocker]# ls
jdk.tar.gz tomcat9 tomcat.tar.gz
[root@localhost mydocker]# mkdir images
[root@localhost mydocker]# cd images/
[root@localhost images]# ls
[root@localhost images]# docker save -o /mydocker/images/redis.tar redis
[root@localhost images]# ls
redis.tar
二 加载镜像
[root@localhost mydocker]# 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
-i 指定加载的镜像
[root@localhost images]# docker rmi redis
Untagged: redis:latest
Untagged: redis@sha256:6cddb3822e19f09a6a369c35680562ddd2e44bd3bfd6fe25ec6456c42f45728b
Deleted: sha256:ccee4cdf984f11952441cbab30146dae792c8d9fb668e762c78a49e7db858082
Deleted: sha256:a4f3d68d06ee9aec1862695818528930f0e889f5c892da8be4c06759dc2e8f86
Deleted: sha256:02c22c39334cefb22054330d3be804a3046286d7f0a47d83f5f25be13f4e635e
Deleted: sha256:2d01997f1c500789fc369f5440ea810257641af6fbb1d4eaeb9558d94ea8879d
Deleted: sha256:f448a5cc1367794bb2f15d887438c8b43f2324ee3523f5d95c15997685cc816d
Deleted: sha256:e481db33c0c73ee7de5ecda57c21fcfb7eeeff7d22fcc4ad0166b0bf64a63a32
[root@localhost images]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost images]# docker load -i /mydocker/images/redis.tar
89ce1a07a7e4: Loading layer [==================================================>] 338.4kB/338.4kB
9eef6e3cc293: Loading layer [==================================================>] 4.194MB/4.194MB
ee748697d275: Loading layer [==================================================>] 31.7MB/31.7MB
f1f7964d40af: Loading layer [==================================================>] 2.048kB/2.048kB
3d9fda8ff875: Loading layer [==================================================>] 3.584kB/3.584kB
Loaded image: redis:latest
[root@localhost images]# docker image
Usage: docker image COMMAND
Manage images
Commands:
build Build an image from a Dockerfile
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Display detailed information on one or more images
load Load an image from a tar archive or STDIN
ls List images
prune Remove unused images
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rm Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
Run 'docker image COMMAND --help' for more information on a command.
[root@localhost images]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest ccee4cdf984f 8 days ago 105MB
最后
以上就是欢喜魔镜为你收集整理的Docker使用save和load进行保存镜像到本地和从本地加载镜像的全部内容,希望文章能够帮你解决Docker使用save和load进行保存镜像到本地和从本地加载镜像所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复