Docker是一个开放的平台,将应用和基础设施分隔开来, 方便快速的交付软件。利用docker的提供的方法可以快速的测试和部署代码,显著的减少写代码和部署直接的延迟。

Docker 平台(The Docker platform):

  container:单独的可以打包运行应用的环境。这些隔离、安全的环境可以让你在主机上同时运行许多container,因为不需要多余的虚拟机监控程序,因此container是很轻量级的,但是它可以直接运行在主机的内核上,因此相比虚拟机,你可以在你给的硬件上运行更多的容器。

Docker provides the ability to package and run an application in a loosely isolated environment called a container.

  Docker 提供了工具和平台让你管理你容器的生命周期。

  • 在容器中开发你的应用和支持组件
  • 容器成为你开发和测试的独立单元
  • 当你准备好在生产环境部署你的应用时,它可以作为一个容器或者编排的服务。无论在你的生产环境是本地数据中心还是云提供的,或者二者的混合,容器的工作方式都是一样的。

Docker 引擎(Docker Engine):

  • Docker 引擎是客户端-服务端的应用(c/s client-server),有如下重要的组件:
  • 守护进程:A server which is a type of long-running program called a daemon process (the dockerd command).
  • REST API: A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
  • 客户端:A command line interface (CLI) client (the docker command).

    

  可以使用CLI或者REST API 通过脚本或者CLI命令和docker 守护进程进行交互。

  守护进程创建并管理docker对象。如容器,镜像,网络和卷等。

使用Docker可以做什么?

快速,持续交付你的应用(Fast, consistent delivery of your applications)

Containers are great for continuous integration and continuous delivery (CI/CD) workflows.

响应式部署和扩展(Responsive deployment and scaling)

在同样的硬件上运行更多的工作负载(Running more workloads on the same hardware)

Docker架构(Docker architecture)

Docker 采用C/S架构,客户端发送命令给docker守护进程,去构建,运行,分发你的docker容器。客户端和守护进程可以运行在同一个机器上,也可以通过客户端连接远程的docker守护进程。docker客户端和守护进程通过REST API,UNIX 端口 或者网络接口进行通信。

  

Docker守护进程 Docker daemon (dockerd):

  监听dockerAPI 请求和管理docker对象(镜像,容器,网络,卷)一个docker的守护进程同样可以与其他docker守护进程交互去管理其他docker服务。

Docker客户端 Docker client(docker):

  docker客户端是和docker交互的主要方式,当你使用命令例如:docker run,客户端会通过Docker API发送请求给dockerd。docker客户端可以和多个守护进程交互。

Docker registries:

  用来存储docker镜像。You can even run your own private registry. If you use Docker Datacenter (DDC), it includes Docker Trusted Registry (DTR).

  当使用docker pull 或者docker run命令,需要的镜像会在你配置的仓库拉取下来。当你用docker push命令,你的镜像就会推送到你配置的远程仓库。

Docker 对象(Docker objects):

  镜像(IMAGES):An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization.

  容器(CONTAINERS):A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI.

  docker run command:

$ docker run -i -t ubuntu /bin/bash

  当你运行这个命令后,会发生如下事情:

  1. 如果你本地没有ubuntu,docker会去你配置的仓库拉取,和手动运行docker pull ubuntu 一样。
  2. docker创建了一个新的容器,和手动运行docker container create 命令一样。
  3. docker分配一个可读写的文件给容器作为它的最后一层,它允许容器在本地环境中去创建或修改。
  4. docker会通过默认网络去连接容器,这个是因为你没有给他分配任何网络选项,包含分配一个IP地址给容器。默认情况下,容器会通过主机的网络去连接外部网络。
  5. docker 启动容器并执行/bin/bash。因为容器以交互的方式连接到终端(由于-i 和-t 标签),你可以用你的键盘去输入内容而通过终端去显示输出结果。
  6. 当你输入 exit 结束 /bin/bash 命令,容器停止了但是并未删除,你可以重新启动它或者删除它。

SERVICES:

  允许跨多个docker守护进程扩展容器,这些守护进程通过docker API进行通信。一个服务允许你定义所需的状态,例如在给定时间提供足够数量可用的服务。默认情况下,服务会负载到每一个工作节点。

CentOS安装docker:https://docs.docker.com/install/linux/docker-ce/centos/

Docker run hello-world

启动docker:systemctl start docker

运行hello world:docker run hello-world

[root@tiandz ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:d1668a9a1f5b42ed3f46b70b9cb7c88fd8bdc8a2d73509bb0041cf436018fbf5
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:
. The Docker client contacted the Docker daemon.
. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
. 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/

官方文档:https://docs.docker.com/engine/docker-overview/

最新文章

  1. 安装Yeoman,遇到的问题
  2. MySQL 数据备份与还原
  3. 编写一个Singleton程序(单例)
  4. java文件中文在MyEclipse中打开变成了乱码
  5. android 的四种枚举Context.MODE_PRIVATE
  6. javascript 学习资料网址一览
  7. delphi中设置系统时间方法
  8. vue+vuex初入门
  9. hdu_4547_CD操作(在线LCA)
  10. el-table中单数行与双数行设置不同的背景颜色
  11. Centos7配置SVN服务端
  12. js获取元素属性值为空的原因和解决办法
  13. Elisp 中变量赋值函数 set 与 setq 辨析
  14. POIUtils 读取 poi
  15. 吴恩达课后作业学习1-week3-homework-one-hidden-layer
  16. IntelliJ IDEA导入多个eclipse项目到同一个workspace下
  17. Spring MVC 原生API
  18. springboot 文件上传和下载
  19. PCA 原理
  20. 【BZOJ】1588: [HNOI2002]营业额统计

热门文章

  1. VS中消除ANSI API警告
  2. sort的使用
  3. Fluent_Python_Part4面向对象,09-pythonic-obj,Python风格的对象
  4. git 操作详情
  5. idea2018.3.6,离线使用maven的方法
  6. Notepad++查看文本文件的总的字符数、GBK字节数、UTF8字节数
  7. jquery中 $(xxx).each() 和 $.each()的区别,以及enter键一键登录
  8. Suffix Tree(后缀树)
  9. 一个IP与多个域名绑定
  10. 最全BT磁力搜索引擎,国外最受欢迎的BT-磁力网站(整理分享,每日不断更新...)