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

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. [php]在PHP中读取和写入WORD文档的代码

    测试平台windows 使用的windows的com主键. <? // 建立一个指向新COM组件的索引 $word = new COM("word.application") ...

  2. Junit4测试报错

    1.字符串数组越界 java.lang.String IndexOutOfBounds Exception:String index out of range:-1 导致: Transaction r ...

  3. java.io.FileNotFoundException: /opt/apache-tomcat-7.0.57/conf/server.xml (权限不够)

    1 错误描述 youhaidong@youhaidong:~$ cd /opt/apache-tomcat-7.0.57 youhaidong@youhaidong:/opt/apache-tomca ...

  4. Struts2(三) 配置struts.xml的提示(在不联网的情况下)

    开发过程中如果可以上网,struts.xml 会自动缓存dtd,提供提示功能.如果不能联网需要我们配置本地dtd,这样才能让struts2 产生提示 1.首先,在EClipse中依次点击工具栏中的wi ...

  5. 版本控制工具--svn和git的使用(一) -----版本控制的好处以及分类

    版本控制工具 版本控制VCS(Version Control Systems)是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统.这个系统可以自动帮我们备份文件的每一次更改,并且可以 ...

  6. 使用 github 做代码管理,知道这些就够了

    只要掌握了下面的常用命令,基本上用使用 github 就没有问题.github 有两种认证方式,一种是通过 ssh 私钥的方式,一种通过 https 的账号名和密码.ssh 方式需要创建本地秘钥并且添 ...

  7. Fragment加载方式与数据通信

    一.加载方式 1. 静态加载 1.1 加载步骤 (1) 创建fragment:创建自定义Fragment类继承自Fragment类,同时将自定义Fragment类与Fragment视图绑定(将layo ...

  8. POJ 2195 Going Home (费用流)

    题面 On a grid map there are n little men and n houses. In each unit time, every little man can move o ...

  9. 【洛谷2015】【CJOJ1976】二叉苹果树

    题面 Description 有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的结点)这棵树共有N个结点(叶子点或者树枝分叉点),编号为1-N,树根编号一定是1.我们用一根树枝两端连 ...

  10. [UVA 10529]Dumb Bones

    题面在这里 题意 放\(n\)个相连的骨牌,每次放的时候有\(pl\)的概率往左倒,有\(pr\)的概率往右倒,骨牌倒的时候可能会打翻左边相邻或者右边相邻的骨牌,并引起连锁反应直到最后一个骨牌旁边没有 ...