<<Docker就是这么简单>> 第一章 镜像

第一个docker镜像

在我们安装完docker后, 我们可以通过运行官方的hello-world来验证Docker是否安装成功.
使用命令: docker pull hello-world 拉取验证镜像.

(base) xxf@MacBook-Pro ~ % docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:9f6ad537c5132bcce57f7a0a20e317228d382c3cd61edae14650eec68b2b345c
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

我们已经通过命令行, 在DockerHub上拉取了我们的第一个镜像, 使用命令查看当前环境下所有的镜像信息:docker images

(base) xxf@MacBook-Pro ~ % docker images
REPOSITORY              TAG                    IMAGE ID       CREATED         SIZE
hello-world             latest                 d1165f221234   3 months ago    13.3kB

使用命令:docker run heelo-world 运行我们第一个docker镜像

(base) xxf@MacBook-Pro ~ % docker run hello-world

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仓库拉取, 运行镜像的流程, 是不是很简单, 没有想象的那么复杂. 接下来我们保持这种实战和尽量的简单方法, 进入我们的学习吧.

虽然概念很枯燥, 但是我们会尽量以生活中的案例来举例, 让概念更简单一些.

docker和vm虚拟机, docker镜像和docker容器, 他们有什么区别呢?

让我们先从买不起的房子说起.

VM -- Container
虚拟机/容器/镜像

        虚拟机就好比左图中的独栋建筑, 拥有独立的车库/排污系统/安保系统/花园/泳池,系统运行多个虚拟机就好比多个联排独栋别墅一样, 彼此隔离, 互不干涉.同时每栋房子都独立拥有完整的居住环境.
        容器就像右图中的高层小区住宅, 大家共享小区园林, 共享同一套排污系统/安保系统/园林/泳池/地下车库. 而我们的docker呢就好比是某一个楼盘开发商的产品, 比如恒某大公司. docker只是容器技术的一种实现方式. 就像整个房地产行业, 还有万某科, 碧某园一样.
        镜像, 就如装修公司(DockerHub)给我们提供的装修样板间,有很多装修风格, 比如中式/明清风/唐代风格(mysql镜像, redis镜像... ) 当我们需要中式风格的时候, 只需要docker pull 中式风格, 一套满意的中式居住环境就已经装修到房子里啦. 当我们入住的时候, docker run 中式风格. 就可以正式入住了. 至此, 概念的区别已经讲清楚了. 如果还想了解更枯燥的概念, 可以接着往下看. 不过笔者建议刚开始就到这里就好了, 等学完以后再回过来看枯燥的概念会更容易理解.

工作原理/优劣势比较
工作原理/优劣势比较
架构图

.....未完待续

笔者来自疯狂创客圈的技术爱好者, 欢迎关注我们的博客和加入我们.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容