博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker镜像制作
阅读量:5753 次
发布时间:2019-06-18

本文共 5152 字,大约阅读时间需要 17 分钟。

通过提交保持一个镜像的改变永远有效

问题:

往往在我们删除一个容器后又用相同镜像进行部署时,我们做的更改的那个镜像里面的数据会丢失,假如我们想要重新使用我们改变后的镜像作为一个源,怎么做?请看解决方案

解决:

我们可以通过docker commit来完成,并且定义一个新的镜像

$ docker run -t -i ubuntu:14.04 /bin/bash

[root@c720120 ~]# docker run -t -i ubuntu:14.04 /bin/bash

root@8c892f17fc59:/# apt-get update Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]Get:2 http://security.ubuntu.com trusty-security/universe Sources [88.8 kB]Get:3 http://security.ubuntu.com trusty-security/main amd64 Packages [919 kB]Ign http://archive.ubuntu.com trusty InRelease                                 Get:4 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]             Get:5 http://security.ubuntu.com trusty-security/restricted amd64 Packages [18.1 kB]Get:6 http://archive.ubuntu.com trusty-backports InRelease [65.9 kB]           Get:7 http://security.ubuntu.com trusty-security/universe amd64 Packages [290 kB]Get:8 http://archive.ubuntu.com trusty Release.gpg [933 B]                     Get:9 http://archive.ubuntu.com trusty-updates/universe Sources [253 kB]       Get:10 http://security.ubuntu.com trusty-security/multiverse amd64 Packages [4725 B]Get:11 http://archive.ubuntu.com trusty-updates/main amd64 Packages [1344 kB]  Get:12 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [21.4 kB]Get:13 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [586 kB]Get:14 http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages [16.0 kB]Get:15 http://archive.ubuntu.com trusty-backports/main amd64 Packages [14.7 kB]Get:16 http://archive.ubuntu.com trusty-backports/restricted amd64 Packages [40 B]Get:17 http://archive.ubuntu.com trusty-backports/universe amd64 Packages [52.5 kB]Get:18 http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages [1392 B]Get:19 http://archive.ubuntu.com trusty Release [58.5 kB]                      Get:20 http://archive.ubuntu.com trusty/universe Sources [7926 kB]             Get:21 http://archive.ubuntu.com trusty/main amd64 Packages [1743 kB]          Get:22 http://archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]    Get:23 http://archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]      Get:24 http://archive.ubuntu.com trusty/multiverse amd64 Packages [169 kB]     Fetched 21.3 MB in 37s (572 kB/s)                                              Reading package lists... Done
[root@c720120 ~]# docker commit 8c89 ubuntu:updatesha256:2292f220bc30f7aa1bb08a795f8ecd5ac58f58a94705c899b1d2d96fa353a584

我们也可以通过diff选项来看在原镜像和现在的镜像之间有哪些改变。

[root@c720120 ~]# docker diff 8c89C /rootA /root/.bash_historyC /tmpC /varC /var/cacheC /var/cache/aptD /var/cache/apt/pkgcache.binD /var/cache/apt/srcpkgcache.binC /var/libC /var/lib/apt/listsA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-backports_InReleaseA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-backports_main_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-backports_multiverse_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-backports_restricted_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-backports_universe_binary-amd64_Packages.gzC /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_InReleaseA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_multiverse_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_restricted_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_universe_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_universe_source_Sources.gzC /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_ReleaseC /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_Release.gpgA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_main_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_multiverse_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_restricted_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages.gzA /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_universe_source_Sources.gzC /var/lib/apt/lists/lockC /var/lib/apt/lists/partialC /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_InReleaseA /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_main_binary-amd64_Packages.gzA /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_multiverse_binary-amd64_Packages.gzA /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_restricted_binary-amd64_Packages.gzA /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_universe_binary-amd64_Packages.gzA /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_universe_source_Sources.gzC /var/lib/dpkgC /var/lib/dpkg/lock

其中A代表新添加的

其中C代表改变的
其中D代表删除的

技术讨论群:190029784

转载于:https://blog.51cto.com/aishangwei/2120802

你可能感兴趣的文章
DBS:同学录
查看>>
Mysql备份系列(1)--备份方案总结性梳理
查看>>
C#开发的高性能EXCEL导入、导出工具DataPie(支持MSSQL、ORACLE、ACCESS,附源码下载地址)...
查看>>
[CareerCup] 1.6 Rotate Image 翻转图像
查看>>
Execution Plan 执行计划介绍
查看>>
29.6. nm - list symbols from object files
查看>>
Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals)爆零记
查看>>
jQuery中$.fn的用法示例介绍
查看>>
Python中的画图初体验
查看>>
又一个半成品库 weblog rpc client
查看>>
关于前端的photoshop初探的学习笔记
查看>>
Java程序员的日常 —— 响应式导航Demo
查看>>
敏捷软件开发宣言--常读常新
查看>>
objective-c内存管理基础
查看>>
httpServlet,GenericServlet,Servlet源码分析
查看>>
easyUI——datebox验证和自定义取消按钮
查看>>
第 20 章 Nagios
查看>>
MagSpoof:能预测并窃取你下一张信用卡号码的廉价设备
查看>>
python接口自动化9-https请求(SSL)
查看>>
MySQL的rpm和源码两种安装操作
查看>>