Docker 的image是运行的基本.
例如我们build一个image时, 在Dockerfile每条指令会产生一个可读写的image, 下一条指令使用上一条指令产生的image为基础, 继续产生image(然后删除上一个image), 如果指令没有对image有修改的动作, 那么可以使用image cache. 所有的指令执行完, 生成最终的image.
然后我们就可以使用image来创建并运行container了.
例如我当前本地有一个images, centos, TAG是centos5, 我需要使用它作为base image, 来创建我自己的image.

[root@150 docker]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos                    centos5             d5844d902074        2 days ago          467.1 MB

创建一个空目录, 并在这个空目录中写一个简单的Dockerfile内容如下 :

# vi Dockerfile
FROM centos:centos5
CMD ["-l"]
ENTRYPOINT ["ls"]

使用docker build .来创建image.

[root@150 docker]# docker build .
Sending build context to Docker daemon  2.56 kB
Sending build context to Docker daemon
Step 0 : FROM centos:centos5---> d5844d902074   # 这个ID是centos:centos5的IMAGE id
Step 1 : CMD ["-l"]---> Running in 9fd2f16fcf97   # 这个ID是执行第一条指令CMD ["-l]时产生的中间过程IMAGE ID---> e253cb9b0ea4   # 这个ID是执行第一条指令CMD ["-l]后产生的IMAGE ID
Removing intermediate container 9fd2f16fcf97   #  移除中间image
Step 2 : ENTRYPOINT ["ls"]---> Running in 52c06c9fae1b  ---> a18fae31b310
Removing intermediate container 52c06c9fae1b
Successfully built a18fae31b310    # 最终的ID, 可以使用docker images看到这个ID
[root@150 docker]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>                    <none>              a18fae31b310        14 minutes ago      467.1 MB
centos                    centos5             d5844d902074        2 days ago          467.1 MB

使用这个image运行

[root@150 docker]# docker run a18fae31b310
total 64
drwxr-xr-x   2 root root 4096 Sep 26 12:21 bin
drwxr-xr-x   4 root root  340 Sep 30 10:29 dev
drwxr-xr-x  39 root root 4096 Sep 30 10:29 etc
drwxr-xr-x   2 root root 4096 May 11  2011 home
drwxr-xr-x   6 root root 4096 Sep 26 12:20 lib
drwxr-xr-x   7 root root 4096 Sep 26 12:20 lib64
drwx------   2 root root 4096 Sep 26 12:19 lost+found
drwxr-xr-x   2 root root 4096 May 11  2011 media
drwxr-xr-x   2 root root 4096 May 11  2011 mnt
drwxr-xr-x   2 root root 4096 May 11  2011 opt
dr-xr-xr-x 372 root root    0 Sep 30 10:29 proc
drwxr-x---   2 root root 4096 May 11  2011 root
drwxr-xr-x   2 root root 4096 Sep 26 12:21 sbin
drwxr-xr-x   3 root root 4096 Sep 26 12:21 selinux
drwxr-xr-x   2 root root 4096 May 11  2011 srv
drwxr-xr-x  13 root root    0 Sep 30  2014 sys
drwxrwxrwt   2 root root 4096 Sep 26 12:21 tmp
drwxr-xr-x  14 root root 4096 Sep 26 12:20 usr
drwxr-xr-x  17 root root 4096 Sep 26 12:19 var[root@150 docker]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                         PORTS               NAMES
ae77e79c4f58        a18fae31b310        ls -l               29 seconds ago      Exited (0) 28 seconds ago                          desperate_lovelace [root@150 docker]# docker rm ae77e79c4f58
ae77e79c4f58
[root@150 docker]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

image的介绍 : 

Introduction

In Docker terminology, a read-only Layer is called an image. An image never changes.

Since Docker uses a Union File System, the processes think the whole file system is mounted read-write. But all the changes go to the top-most writeable layer, and underneath, the original file in the read-only image is unchanged. Since images don't change, images do not have state.

Parent Image

Each image may depend on one more image which forms the layer beneath it. We sometimes say that the lower image is the parent of the upper image.

Base Image

An image that has no parent is a base image.

Image IDs

All images are identified by a 64 hexadecimal digit string (internally a 256bit value). To simplify their use, a short ID of the first 12 characters can be used on the command line. There is a small possibility of short id collisions, so the docker server will always return the long ID.

[参考]

1. http://docs.docker.com/terms/image/

Docker image Introduce相关推荐

  1. docker容器虚拟化技术_Docker,虚拟机和容器的全面介绍

    docker容器虚拟化技术 by shota jolbordi 通过Shota Jolbordi Docker has been a buzzword for tech people for the ...

  2. 时间同步-ntp服务器的搭建(docker版本)

    introduce 用于构建cdm所需要的ntp服务器镜像,实现宿主机和ntpserver同步,ntpserver于ntpclient的同步 项目地址 项目github image build doc ...

  3. 【译文】用Spring Cloud和Docker搭建微服务平台

    by Kenny Bastani Sunday, July 12, 2015 转自:http://www.kennybastani.com/2015/07/spring-cloud-docker-mi ...

  4. 再来过-docker

    $ sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker- ...

  5. 如何删除旧的和未使用的Docker映像

    本文翻译自:How to remove old and unused Docker images When running Docker for a long time, there are a lo ...

  6. VMWare File Format Learning Use VHD File To Boot VMWare CoreOS Docker Configuration And Runnin...

    目录 1. Virtual Machine Introduce 2. Vmware Image File Format 3. VHD File Format 4. Convert VHD File I ...

  7. 尚硅谷docker基础篇 2018版

    typora-root-url: ./image Docker基础篇之快速上手 第一章 Docker简介 是什么? 问题:为什么会有 docker 的出现 一款产品从开发到上线,从操作系统,到运行环境 ...

  8. docker镜像迁移mysql启动报错_README.md

    ### 源码仓库已迁移到 [gitee.com/kuzank](gitee.com/kuzank),此账号下的工程不再提供维护,请移步访问[gitee.com/kuzank](gitee.com/ku ...

  9. Docker 启动Redis

    docker run \-d \-p 6379:6379 \--name redis \-v /home/cgt/redis/data:/data \-v /home/cgt/redis/redis. ...

最新文章

  1. matlab 将矩阵A写入文件
  2. Java实现算法导论中线性规划单纯形算法
  3. 百度母婴技术团队—基于Reactjs实现webapp #1
  4. Tiniux 3.0 / Memory.c / OSMemMalloc 和 OSMemCalloc
  5. 设计模式-行为型模式-中介者模式
  6. spd不能修改服务器内存条的原因,修改内存SPD 解决蓝屏问题
  7. SpringBoot入门第一个简单示例
  8. python数据存储系列教程——python对象与json字符串的相互转化,json文件的存储与读取
  9. 【Python】解析Python中的条件语句和循环语句
  10. Cocostudio生成的UI,触摸屏蔽问题
  11. X509Certificate证书如何获取16位长度serial number?
  12. matlab海底地形数据,海底地形建模器
  13. 一款老飞飞_魅力飞飞脚本研究增加攻击与暴击几率方式探讨源码(附带易语言源码)
  14. nginx错误代码说明,出现原因及解决方法
  15. CorelDRAW制作360安全浏览器图标
  16. 国潮风彩色手绘年俗年画春节插画素材
  17. 小微企业实施数字化转型的困境
  18. SVN操作提示被锁定-清理命令Clean up
  19. Android性能优化之内存优化浅析
  20. matlab多项式计算题目,MATLAB数据分析与多项式计算-习题答案

热门文章

  1. 事业单位职称工资计算机,终于!事业单位绩效工资、职称变了!关系上千万人收入!...
  2. MKL学习——矩阵向量操作
  3. HMM前向算法,维比特算法,后向算法,前向后向算法代码
  4. Cortex-M3 的SVC、PendSV异常,与操作系统(ucos实时系统)(转)
  5. springboot之session、cookie
  6. bug__android studio 出现布局文件不提示,且点击代码不能跟踪代码
  7. EditText 空指针问题
  8. ORA-20446: The owner of the job is not registered ORA-06512: at SYSMAN.MGMT
  9. 批量获取远程计算机MAC
  10. vue-cli脚手架的.babelrc文件