Docker: save the running docker container as a docker image and save it to the local tar package "only verify the packaging part"

1. Save the running docker container as a docker image and save it to a local tarball

1、docker commit <容器id> <镜像名>:<tag>     ---- 将容器保存成镜像,tag比如说latest
 
保存后 docker images 便可以看到镜像
 
2、docker save -o <tar包名>.tar <镜像名>:<tag>      ---- 将镜像保存为.tar文件,默认保存在当前目录

2. Import the docker image from the tar package

1、docker load -i <tar包名>.tar     ---- 从 tar 包导入镜像
 
导入镜像后,通过 docker images 便可看到导入的镜像。
 
2、docker run -itd -p <本地端口>:<容器端口> <镜像名>:<tag>    ---- 通过镜像起容器

Case "save to tar package only"

charlieli@Charlies-MBP ~ % docker commit 25d78c6caeeb myqinglong:qinglong
sha256:c74fa9cd47eec1799b95d4237abdf7801dd4754bb6e6b61ce2032a45e3d42832
charlieli@Charlies-MBP ~ % docker images
REPOSITORY        TAG        IMAGE ID       CREATED          SIZE
myqinglong        qinglong   c74fa9cd47ee   38 seconds ago   631MB
whyour/qinglong   latest     5997b3824cbe   4 months ago     434MB
node              latest     a283f62cb84b   5 months ago     993MB
charlieli@Charlies-MBP ~ % cd /*****/*****/appsVolumn
charlieli@Charlies-MBP appsVolumn % docker save -o my_qinglong_full_config.tar myqinglong:qinglong

Guess you like

Origin blog.csdn.net/weixin_45827203/article/details/124946378