docker镜像导出和导入

docker镜像导出和导入

api

输入
docker --help
找到
Commands:
镜像管理
image Manage images

输入
docker image
得到镜像管理命令

[root home]# 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

我们用到的就是save保存镜像到某个位置

[root@shixiaodong home]# docker image save --help

Usage:  docker image 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是 -output的缩写

导出命令

docker image save -o /home/des.tar docker.elastic.co/elasticsearch/elasticsearch

REPOSITORY                                      TAG           IMAGE ID       CREATED         SIZE
adoptopenjdk/openjdk8                           latest        bbba8bf4d091   5 months ago    320MB
nacos/nacos-server                              latest        e6a65052d0b1   5 months ago    1.08GB
zyyd-jstx-web                                   v1.0          8e7a7c91bd66   9 months ago    384MB
redis                                           latest        ccee4cdf984f   16 months ago   105MB
hello-world                                     latest        d1165f221234   18 months ago   13.3kB
mcr.microsoft.com/mssql/server                  2019-latest   a8948ed97d80   19 months ago   1.39GB
nacos/nacos-server                              1.4.0         7942818ce6f4   21 months ago   921MB
docker.elastic.co/elasticsearch/elasticsearch   7.7.0         7ec4f35ab452   2 years ago     757MB
kibana                                          7.4.2         230d3ded1abc   2 years ago     1.1GB
elasticsearch                                   7.4.2         b1179d41a7b4   2 years ago     855MB
[ home]# docker image save -o /home/des.tar docker.elastic.co/elasticsearch/elasticsearch

导出注意事项

docker image save -o /home/des.tar docker.elastic.co/elasticsearch/elasticsearch
-o 后面是导出到哪里 在后面是镜像名称,不要用id不然导入后会没有名称和版本号

导入

docker image load -i /home/des.tar
同样看帮助文档

猜你喜欢

转载自blog.csdn.net/shixiaodongmain/article/details/126886482