1 Hello World docker

    $ docke run hello-world

    Unable to find image ‘hello-world:latest’ locally
    latest: Pulling from library/hello-world
    0e03bdcc26d7: Pull complete
    Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
    Status: Downloaded newer image for hello-world:latest

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
    (amd64)
    3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash

    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/

    For more examples and ideas, visit:
    https://docs.docker.com/get-started/


    docker [container] run hello-world
    等价
    docker image pull [library/]hello-world && docker [container] run hello-world[:lastest]

    “Unable to find image ‘hello-world:latest’ locally” :先在本地仓库寻找hello-world,提示没找到
    “latest: Pulling from library/hello-world” :去远程仓库下拉取hello-world:latest

    container:该关键字可以省略
    library:官方提供的image文件都放在library下。使用官方image时可以省略。【latest: Pulling from library/hello-world】
    lastest:标签名称,如果不指定tag,会默认查找tag为latest的image。【latest: Pulling from library/hello-world】


    docker的两个基本单位:image container

    image: docker把应用程序及其依赖打包在image中
    container: image可以看做container的模板。container是image运行时的实体。container可以被创建、启动、停止、删除、暂停等。

    同一个image文件,可以生成多个同时运行的container实例。imagecontainer的关系,就像是面向对象程序设计中的 类 和 实例 一样,image是静态的定义,container是image运行时的实体。
    image文件是通用的,一台机器的image文件拷贝到另一台机器,也可以使用。
    实际开发中,一个image文件往往通过继承另一个image文件,加上一些个性化定制而成。比如可以在centos image基础上(等价最小安装),安装JDK,形成一个包含了JDK的centos image。