将配置好的docker容器提交成新镜像、镜像导出、导入

December 17, 2023
测试
测试
测试
测试
6 分钟阅读

提交新镜像

docker commit -a "镜像作者" -m "提交消息" 容器的id 新镜像的名称:版本号

镜像导出

docker save -o 镜像保存目录 镜像名称:版本号

镜像导入

docker load -i 镜像文件目录 

测试提交镜像、导出镜像

[root@localhost ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
registry.aliyuncs.com/helowin/oracle_11g   latest    3fa112fd3642   6 years ago     6.85GB

[root@localhost ~]# docker commit -m "my oracle" 434bcfed5c5d myoracle:v1     #将ID为434bcfed5c5d的容器提交为myoracle:v1镜像
sha256:2e94ca0525c12fcc8c1ab4db23d9803784b36c8615d5ef8b2a19dd0db6b365df

[root@localhost ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
myoracle                                   v1        2e94ca0525c1   4 seconds ago   6.86GB
registry.aliyuncs.com/helowin/oracle_11g   latest    3fa112fd3642   6 years ago     6.85GB

[root@localhost ~]# docker save -o /root/myoracle-v1 myoracle:v1     #将myoracle:v1镜像导出至myoracle-v1目录

[root@localhost ~]# ls
anaconda-ks.cfg  myoracle-v1

删除myoracle:v1镜像,测试将myoracle-v1镜像目录导入镜像

[root@localhost ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
myoracle                                   v1        2e94ca0525c1   4 weeks ago     6.86GB
registry.aliyuncs.com/helowin/oracle_11g   latest    3fa112fd3642   6 years ago     6.85GB

[root@localhost ~]# docker rmi myoracle:v1     #删除myoracle:v1镜像
Untagged: myoracle:v1
Deleted: sha256:2e94ca0525c10bbf8565d6fc6bfa7437ead898d4fef23ccdb2fec251b8f0017c
Deleted: sha256:aa8d2f40c967fc08259152ce00d35bdc6308c8851ad3d5eaf288a97d2f8abcaf

[root@localhost ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED       SIZE
registry.aliyuncs.com/helowin/oracle_11g   latest    3fa112fd3642   6 years ago   6.85GB

[root@localhost ~]# ll myoracle:v1
-rw------- 1 root root 398452224 3月  12 10:46 mytomcat-v1

[root@localhost ~]# docker load -i myoracle:v1     #将myoracle-v1镜像保存目录导入至docker镜像库中
fb846605e622: Loading layer  26.62kB/26.62kB
Loaded image: myoracle:v1

[root@localhost ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
myoracle                                   v1        2e94ca0525c1   4 weeks ago     6.86GB    #成功导入
registry.aliyuncs.com/helowin/oracle_11g   latest    3fa112fd3642   6 years ago     6.85GB

继续阅读

更多来自我们博客的帖子

如何安装 BuddyPress
由 测试 December 17, 2023
经过差不多一年的开发,BuddyPress 这个基于 WordPress Mu 的 SNS 插件正式版终于发布了。BuddyPress...
阅读更多
Filter如何工作
由 测试 December 17, 2023
在 web.xml...
阅读更多
如何理解CGAffineTransform
由 测试 December 17, 2023
CGAffineTransform A structure for holding an affine transformation matrix. ...
阅读更多