码迷,mamicode.com
首页 > 其他好文 > 详细

Docker Architecture Learning

时间:2014-11-09 15:11:52      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   color   ar   os   使用   

目录

1. Docker简介
2. Docker的使用案例
3. Docker架构
4. 如何安装、部署Docker

 

1. Docker简介

Docker基于Go语言开发,代码托管在 Github上,并遵循Apache 2.0开源协议

Build, Ship and Run Any App, Anywhere
Docker - An open platform for distributed applications for developers and sysadmins.

0x1: Docker的特性

1. Build
Develop an app using Docker containers with any language and any toolchain.

2. Ship
Ship the "Dockerized" app and dependencies anywhere - to QA, teammates, or the cloud - without breaking anything.

3. Run
Scale to 1000s of nodes, move between data centers and clouds, update with zero downtime and more.

0x2: Docker和Virtual Machines(VM)的区别

1. Virtual Machines

bubuko.com,布布扣

Each virtualized application includes

1. the application: which may be only 10s of MB
2. the necessary binaries and libraries
3. an entire guest operating system - which may weigh 10s of GB 

2. Docker

bubuko.com,布布扣

The Docker Engine container

1. the application 
2. its dependencies(Bins/Libs)

It runs as an isolated process in userspace on the host operating system, sharing the kernel with other containers. Thus, it enjoys the resource isolation and allocation benefits of VMs but is much more portable and efficient.

bubuko.com,布布扣

1. 一个Container通常包含应用及应用依赖项,Container用来隔离进程,这些进程主要运行在主机操作系统上的隔离区和用户空间。
这个是明显不同于传统的VMs

2. 传统的硬件虚拟化(例如VMWare、KVM、Xen、EC2)旨在创造一个完整虚拟机。每个虚拟化应用不仅包含应用的二进制文件,还需运行该应用程序所需的库、一个完整的Guest操作系统 

3. 由于所有的容器共享同一个操作系统(以及二进制文件和库),所以,他们明显要比VM小的多,这样,就完全可以在一个物理主机上托管100个VMs(一般VM数量会受到严格限制)。此外,因为它们使用主机操作系统,重启一个VM并不意味着要重启操作系统,因此,容器更加轻便、高效 

4. Docker中的容器效率会更高。因为一个传统的VM、应用、每个应用副本以及每个应用微小的变更都需要重新创建一个完整的VM  
一个新的应用在主机上仅仅包含应用及其二进制文件/库,这样就无需创建一个新的客户机操作系统。 

5. 如果想在主机上运行该应用的几个副本,你甚至无需复制共享的二进制文件,即使你对应用进行了变更,你也无需拷贝变更内容

bubuko.com,布布扣

0x3: Docker技术的核心竞争优势

Docker简单来说就是一个Container的管理工具。而Container就是一个更轻量级的虚拟机,但是这个虚拟机没有操作系统和设备(操作系统是共享的)
container技术目前解决了软件行业的最大问题之一: 应用的共享,配置管理和维护(还有应用的隔离,效率等等),不管是在物理机环境还是云环境
和虚拟机相比,container不仅更轻量,而且配置简化了很多(不用考虑操作系统和设备的配置)。这样做有2个好处

1. 是写应用的人不用管操作系统的事了(我只会写JAVA,不懂Linux,没关系,你把JAVA相关的配置搞好就好了),因为应用都在container里面
2. container既可以部署在笔记本的操作系统上,也可以部署到云环境,只要操作系统一样,其它区别都没关系。并且不需要安装,解压等等(这个类似于虚拟机,但是虚拟机要考虑虚拟机容器的不同,而对于

container,只要操作系统一样就行了)。从配置管理来看,Container可以做增量的管理

Relevant Link:

http://blog.csdn.net/u012601664/article/details/39547319
http://special.csdncms.csdn.net/BeDocker/
http://www.csdn.net/article/2014-02-01/2818306-Docker-Story
http://www.csdn.net/article/2014-06-20/2820325-cloud-Docker
http://www.csdn.net/article/2014-07-02/2820497-what‘s-docker

0x4: Docker在线入门教程

https://www.docker.com/tryit

 

2. Docker的部署情况

0x1: 成功使用案例

1. Gilt: Distributed applications to scale
Gilt Groupe, Inc., a leading online shopping company, operates an online flash sale site for men, women, girls, boys, and unisex in the United States.

2. Yelp: Continuous Integration
Yelp (NYSE: YELP) connects people with great local businesses. Yelp had a monthly average of 120 million unique visitors in Q4 2013

3. Spotify: Continuous Delivery
Spotify streams music to more than 40 million users in 57 countries around the world.

4. Baidu: Platform-as-a-Service (PaaS)
Baidu, Inc. is the number one Chinese-language Internet search provider that has a broad portfolio of products including social-networking products, music products, mobile related products and other products and services.

5. New Relic: Distributed Applications Composition
New Relic is a Software Analytics company that makes sense of billions of metrics across millions of apps.

6. Rackspace: Continuous Integration
Rackspaces email service (MailGun) that allows you to send, receive and track emails effortlessly. Mailgun has made significant investments in building a Docker-centric continuous integration system for this service where high-availability is a requirement.

7. Yandex: Platform-as-a-Service (PaaS)
Yandex is an European Internet company and the largest search provider in Russia. 
Yandex’s Platform-as-a-Service (PaaS) is using Docker for infrastructure virtualization and application isolation.

8. Cambridge: Continuous Delivery
Cambridge Healthcare provides online access to health records and analytics for both patients and clinicians. They replaced several AWS AMIs with a single bare metal host running Docker to speed up their Jenkins-based continuous delivery pipeline.

9. eBay: Easy Application Deployment
eBay Now is eBays local, same day delivery service. In this use case, Senior Architect Ted Dziuba discusses his use of Docker in a continuous integration process. He uses Docker to implement an efficient, automated path from the developers laptop through test and QA.

Relevant Link:

https://www.docker.com/resources/usecases/
https://www.docker.com/

 

3. Docker架构

0x1: the open-source application container engine

https://github.com/docker/docker

0x2: Docker的架构

bubuko.com,布布扣

Docker架构下的三种运行方式

1. 作为守护进程,在Linux主机上管理LXC容器
    1) 使用namespaces来做权限的控制和隔离
    2) 使用cgroups来进行资源的配置
    3) 通过aufs来提高文件系统的资源利用率
    aufs是UnionFS的一种,它可以把对文件系统的改动当成一次commit一层层的叠加。这样的话多个容器之间就可以共享他们的文件系统层次。这样的话极大的节省了对存储的需求,并且也能加速容器的启动

2. 作为一个CLI,与守护进程的REST API进行对话(docker run ...)

3. 作为仓库的客户端,分享你所构建的内容(docker pull, docker commit)  

0x3: Docker源码学习

http://www.infoq.com/cn/articles/docker-source-code-analysis-part1
http://www.infoq.com/cn/articles/docker-source-code-analysis-part2
http://www.infoq.com/cn/articles/docker-source-code-analysis-part3

Relevant Link:

http://www.csdn.net/article/2014-06-20/2820325-cloud-Docker
http://www.infoq.com/cn/dockers/
http://yeasy.gitbooks.io/docker_practice/
https://docker.cn/p/
http://www.csdn.net/article/a/2014-06-18/15819053

 

4. 安装、部署、使用Docker

0x1: Docker Installation Based On Red Hat (64 bit)

https://docs.docker.com/installation/rhel/
https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F
https://code.csdn.net/u010702509/docker_redhat

0x2: Docker Installation Based On ubntu 12.04 (64 bit)

1. 安装、升级内核
//Docker的运行需要Linux内核提供相应的支持
sudo apt-get update
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo reboot

2. 第一次添加Docker的repository到你的本地秘钥库
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo apt-get update
sudo apt-get install lxc-docker
//期间会遇到一个警告,说这个包不可靠,你只需要回复yes然后继续安装就可以了

3. 官方也提供了一个简单脚本帮助你安装,你可以用curl来获取这个脚本然后执行安装
curl -s https://get.docker.io/ubuntu/ | sudo sh

4. 下载安装ubuntu的镜像封装到一个沙箱中
sudo docker run -i -t ubuntu /bin/bash

0x3: Docker Installation Based On ubntu 13.04 (64 bit)

1. 确认是否安装了AUFS
sudo apt-get update
sudo apt-get install linux-image-extra-`uname -r`

2. 之后的步骤同ubntu 12.04 (64 bit)

Relevant Link: 

https://code.csdn.net/u010702509/docker_ubntu 

0x4: Docker简单命令使用

关于Docker的使用,最好的方法还是去官方提供的在线模拟运行网站,看再多的理论都不如亲自动手搭建部署实践

https://www.docker.com/tryit

Relevant Link:

https://code.csdn.net/u010702509/docker_puppet
https://code.csdn.net/u010702509/docker_shareimage
https://code.csdn.net/u010702509/docker_buildimage
https://code.csdn.net/u010702509/docker_basic
https://code.csdn.net/u010702509/docker/file/Docker.md

0x5: Hello word Docker Image使用

我们知道,Docker是一种面向应用封装的虚拟化环境,我们在理解和使用Docker的使用,一个好的方式是将一个应用包括它的依赖库整体看成一个Image,而所有的Images都被包括在一个整体的Container里面,客户端通过Docker Client以RESTFUL API的方式和LXC Docker Server进行通信。以上所有的组件整合起来,合成为Docker,这就是Docker的架构

我们在使用Docker的使用,离程序员最近的就是Image,也就是一个个封装好的应用环境

1. 所有的实例你都需要在你的机器中运行docker进程,后台运行docker进程,简单演示
sudo docker -d &

2. 现在你可以运行Docker客户端,默认情况下所有的命令都会经过一个受保护的Unix socket转发给docker进程,所以我们必须运行root或者通过sudo授权
sudo docker help

3. 下载ubuntu base镜像
# Download an ubuntu image
sudo docker pull ubuntu

4. 执行一个进程
CONTAINER_ID=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done")
sudo docker logs $CONTAINER_ID

5. 查看日志文件来确认它是否正常工作
sudo docker attach -sig-proxy=false $CONTAINER_ID

6. 连接到容器实时查看结果
sudo docker ps

7. 查看正在运行的进程
sudo docker stop $CONTAINER_ID

8. 当我们不需要时停止容器
sudo docker ps

Relevant Link:

https://code.csdn.net/u010702509/docker_helloword

0x6: JAVA Tomcat Running Environment Installation

http://blog.csdn.net/junjun16818/article/details/34845613#comments

 

Copyright (c) 2014 LittleHann All rights reserved

 

Docker Architecture Learning

标签:des   style   blog   http   io   color   ar   os   使用   

原文地址:http://www.cnblogs.com/LittleHann/p/4083943.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!