创建自己的镜像:通过现有的镜像来创建自己的镜像。

1、首先拉取一个镜像到本地
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              12.04               5b117edd0b76        11 months ago       104 MB

2、进入容器
$ sudo docker run -it ubuntu:12.04 bash
$ root@7a61867cf4c5:/#

3、修改容器,这里我们安装zip包
# apt-get install zip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package zip
需要更新,我们更新
root@7a61867cf4c5:/# apt-get update
结束后
root@7a61867cf4c5:/# apt-get install zip
修改后退出
root@7a61867cf4c5:/# exit
exit

4、保存容器到镜像
$ sudo docker commit -m 'test' -a 'zhouhai' 7a61867cf4c5 ubuntu:latest
sha256:763d1f40ca6b4a801a78b39ddeb526be44330bb65f4ef94dc9267e4f0985627c
查看镜像
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              763d1f40ca6b        13 seconds ago      133 MB
ubuntu              12.04               5b117edd0b76        11 months ago       104 MB

5、导出新产生的镜像
$ sudo docker save -o /home/zh/ubuntu_zip.tar ubuntu:latest

6、删除新产生的镜像
$ sudo docker rmi -f ubuntu:latest
Untagged: ubuntu:latest
Deleted: sha256:763d1f40ca6b4a801a78b39ddeb526be44330bb65f4ef94dc9267e4f0985627c
Deleted: sha256:e6e720db3d4ce9b5b07f4e77e6c0608add2d83b218f2b3107800682e29be246b
查看一下
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              12.04               5b117edd0b76        11 months ago       104 MB

7、导入刚才保存的镜像
$ sudo docker load --input /home/zh/ubuntu_zip.tar
83c5e276e2c0: Loading layer [==================================================>] 29.82 MB/29.82 MB
Loaded image: ubuntu:latest
查看一下
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              763d1f40ca6b        16 minutes ago      133 MB
ubuntu              12.04               5b117edd0b76        11 months ago       104 MB
进入容器
$ sudo docker run -it ubuntu:latest bash
root@9d1ab685dd74:/# zip
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help
大功告成!

通过修改然后commit的方式创建自己的镜像的更多相关文章

  1. 创建Python数据分析的Docker镜像+Docker自定义镜像commit,Dockerfile方式解析+pull,push,rmi操作

    实例解析Docker如何通过commit,Dockerfile两种方式自定义Dcoker镜像,对自定义镜像的pull,push,rmi等常用操作,通过实例创建一个Python数据分析开发环境的Dock ...

  2. HiveServer2 的jdbc方式创建udf的修改(add jar 最好不要使用),否则会造成异常: java.sql.SQLException: Error while processing statement: null

    自从Hive0.13.0开始,使用HiveServer2 的jdbc方式创建udf的临时函数的方法由: ADD JAR ${HiveUDFJarPath} create TEMPORARY funct ...

  3. 使用自签名的方式创建Docker私有仓库

    Docker推荐使用CA机构颁发的TLS(Transport Layer Security Protocol)证书来保护docker仓库的安全,但是我们也可以选择使用HTTP或者自签名证书的方式实现本 ...

  4. 11g使用非duplicate方式创建物理standby要注意的问题总结

    在上篇博文中,使用了duplicate方式来创建物理standby http://blog.csdn.net/aaron8219/article/details/38434579 今天来说说在11g中 ...

  5. docker commit命令创建新的镜像

    docker commit命令创建新的镜像 1.运行容器 2.修改容器 3.将容器保存为新容器 (1)运行容器 [root@cmdb-server docker]# docker run -ti ce ...

  6. VB 在Visio 2010 以编程方式创建子进程图

    在2010年Visio以编程方式创建子进程图 Office 2010  https://msdn.microsoft.com/en-us/library/gg650651.aspx   简介: 学习如 ...

  7. dotnet core 通过修改文件头的方式隐藏控制台窗口

    原文:dotnet core 通过修改文件头的方式隐藏控制台窗口 在带界面的 dotnet core 程序运行的时候就会出现一个控制台窗口,本文告诉大家使用最简单方法去隐藏控制台窗口. 最近在使用 A ...

  8. docker的使用---创建新的镜像(通过修改容器,个人练手理解过程记录,不推荐使用)

    docker基础命令 ##列出docker客户端命令 docker docker container --help ##显示docker的版本和信息 docker --version docker v ...

  9. 2018-9-30-dotnet-core-通过修改文件头的方式隐藏控制台窗口

    title author date CreateTime categories dotnet core 通过修改文件头的方式隐藏控制台窗口 lindexi 2018-09-30 18:36:43 +0 ...

随机推荐

  1. AHB/APB简介

    AHB AHB总线互联结构图 随着深亚微米工艺技术日益成熟,集成电路芯片的规模越来越大.数字IC从基于时序驱动的设计方法,发展到基于IP复用的设计方法,并在SOC设计中得到了广泛应用.在基于IP复用的 ...

  2. 【转载】使用SDL播放YUV图像数据(转)

    SDL提供了针对YUV格式数据的直接写屏操作.废话不多说,直接上代码吧/** * file showyuv.c * author: rare * date: 2009/12/06 * email: d ...

  3. FusionCharts封装-dataset和categories

    Chart.java: /** * @Title:Chart.java * @Package:com.fusionchart.model * @Description:FusionCharts 封装d ...

  4. apache配置,禁止ip访问web站点

    由于一台服务器上面部署了好几个应用,对应不同的域名,如果用户知道ip地址的话,直接用户ip地址访问,会显示第一个虚拟主机的页面(更改了虚拟主机的顺序,每次都是显示第一个).这样对用户造成不好的印象,所 ...

  5. Struts2实现文件上传报错(四)

    1.具体错误如下 2014-5-2 21:38:29 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error 严重: Exception oc ...

  6. hdu5887 Herbs Gathering

    神他妈随便写写就能过- 暴力枚举每个取不取 两个剪纸: 1.当剩下可用的时间小于最少需要用的时间 跳出 2.当剩下的植物按照理想情况(甚至可以取一部分)得到的极限答案比已经求出的答案大 跳出 #inc ...

  7. xml的SAX解析和dom解析的区别

    一,区别 DOM解析 SAX解析 原理: 一次性加载xml文档,不适合大容量的文件读取 原理: 加载一点,读取一点,处理一点.适合大容量文件的读取 DOM解析可以任意进行增删改成 SAX解析只能读取 ...

  8. 异常-----freemarker.template.TemplateException: Expected collection or sequence. datas evaluated instead to freemarker.core.HashLiteral$SequenceHash on line 7, column 18 in inc/select.ftl.

    1.错误描述 六月 26, 2014 11:26:27 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

  9. 【Luogu3806】点分治(点分治)

    [Luogu3806]点分治(点分治) 题面 题目描述 给定一棵有n个点的树 询问树上距离为k的点对是否存在. 输入格式: n,m 接下来n-1条边a,b,c描述a到b有一条长度为c的路径 接下来m行 ...

  10. 【CJOJ1372】【洛谷2730】【USACO 3.2.5】魔板

    题面 Description 在成功地发明了魔方之后,鲁比克先生发明了它的二维版本,称作魔板.这是一张有8个大小相同的格子的魔板: 1 2 3 4 8 7 6 5 我们知道魔板的每一个方格都有一种颜色 ...