技術棧:
1. 構建系統
2. 鏡像倉庫
3. 宿主機管理
4. 配置管理
5. 部署
6. 編排
7. 日志
8. 監控
鏡像:
1. 如果用戶像往常一樣運行包安裝命令,這些永遠也用不上的緩存包文件將會永遠地成為鏡像的一部分。不過,如果用戶在同一條安裝命令中刪除它們,這些文件就會像從未存在過一樣。
RUN xxxxxxxxxxxxxxxxxxx \
&& xxxxxxxxxxxxxxxxxxx \
&& rm -f ......
- 通過環境變量將配置傳遞給容器內部
- 當用戶需要包裝一個無法通過環境變量配置的服務時,使用模板文件,使用一個入口點腳本,獲取環境變量並在文件系統上生成配置文件,然后調用實際進程,該進程將在啟動時讀取那些新生成的配置文件。
讓鏡像在Docker變化時對自身進行重新配置,docker-gen這個工具在Docker提供的容器信息基礎上,使用提供的模板來生成配置文件,它動作的方式是它會監視或輪詢Docker進程以獲取容器內的變化(添加、刪除等),並在發生變化時從模板重新生成配置文件。 https://github.com/jwilder/docker-gen - 將日志文件鏈接到標准輸出,如在nginx中配置
access_log /var/log/nginx/access.log main;
在Dockerfile中,將/dev/stdout鏈接到該文件
RUN ln -sf /dev/stdout /var/log/nginx/access.log
私有倉庫
1. 加固(SSL、認證) https://docker.github.io/registry/deploying/
基於令牌的認證方式是唯一可供選擇的安全選項
- 最小化Docker鏡像 docker-squash https://github.com/jwilder/docker-squash
在生產環境中使用Docker的一些標准:
1. 在一個構建系統中構建所有鏡像
2. 不要使用或禁止使用非標准做法
3. 使用標准基礎鏡像
4. 使用Docker進行集成測試
配置
由於配置管理擅長的是裝配宿主機,因而它們在新的容器化的世界里並沒有多少用武之地。它們的作用也從負責配置整個系統轉變成只是負責配置運行這些應用服務的基礎設施,這包括從Docker宿主機的配置到Mesos集群的搭建等。
Chef
https://github.com/chef-cookbooks/docker
https://github.com/chef-boneyard/chef-container
Ansible
https://github.com/angstwad/docker.ubuntu
http://docs.ansible.com/ansible/docker_module.html
Salt Stack
Puppet
https://forge.puppet.com/garethr/docker/readme
存儲引擎
https://labs.ctl.io/
查看鏡像分層的工具 Image Layers https://imagelayers.io/
AUFS
DeviceMapper 預分配thin provisioning
https://www.kernel.org/doc/Doc ... pper/
在生產環境下應用devicemapper引擎時請記得一定要設置成使用真實的塊設備來存儲數據和元數據設備。
https://github.com/docker/dock ... apper
BTRFS
https://btrfs.wiki.kernel.org/index.php/Main_Page
OverlayFS
https://git.kernel.org/cgit/li ... s.txt
VFS 不提供寫時復制,不太適用於生產環境,但依舊算是掛載Docker卷的一個不錯的解決方案,,在FreeBSD這樣的非Linux平台上運行
網絡
零配置網絡zeroconf http://zeroconf.org/
多主機的容器間通信
大使模式(ambassador pattern) https://docs.docker.com/engine ... king/
開放虛擬交換機(OVS)和GRE隧道: 用OVS創建一個網橋來取代默認的docker0,然后在內網的宿主機之間創建一個安全的GRE隧道。
https://goldmann.pl/blog/2014/ ... osts/
libnetwork https://github.com/docker/libnetwork
swarm https://github.com/docker/swarm
共享網絡命名空間
kubernetes http://kubernetes.io
pod https://github.com/GoogleCloud ... ds.md
啟動容器時帶上參數--net=container:NAME_or_ID,就可以將該容器加入到NAME_or_ID容器的“基礎”網絡命名空間
https://speakerdeck.com/gyre00 ... iners
Docker允許用戶在創建容器的時候和它的宿主機共享網絡命名空間,該宿主機本身在PID 1進程的命名空間里運行它的網絡棧,對於容器來說它們可以很輕松地加入宿主機的網絡命名空間里,即:容器的網絡棧和宿主機之間是共享的。--net=host
IPv6 當前Docker已經加入了對IPv6的支持 http://docs.docker.com/engine/ ... king/
pipework
https://github.com/jpetazzo/pipework
pipework鏡像 https://hub.docker.com/r/dreamcat4/pipework/
weave
https://github.com/weaveworks/weave
安全增強 http://www.weave.works/weave-net-cryptography-faq/
可視化 weave scope
https://github.com/weaveworks/scope
http://thenewstack.io/how-to-d ... orks/
快速網絡路徑 http://www.weave.works/weave-fast-datapath/
Docker插件系統
https://blog.docker.com/2015/0 ... gins/
把weave當做Docker的插件使用 http://www.weave.works/weave-a ... ugin/
flannel
https://github.com/coreos/flannel
VXLAN https://en.wikipedia.org/wiki/ ... e_LAN
etcd https://github.com/coreos/etcd
calico (3層解決方案) 原生的IPv6支持,分布式BGP路由
http://www.projectcalico.org
ClusterHQ powerstrip https://github.com/ClusterHQ/powerstrip
調度
Mesos+marathon
優勢資源公平算法 https://www.cs.berkeley.edu/~alig/papers/drf.pdf
Kubernetes
OpenShift (Red Hat) https://www.openshift.com/open ... more/
Atomic項目 http://www.projectatomic.io
Red Hat容器安全標准 https://securityblog.redhat.co ... arts/
服務發現
最低要求:服務注冊/服務聲明、服務查找/服務發現
服務注冊的兩種實現方式:
1. 把服務注冊的模塊直接嵌入到應用服務的源代碼里
2. 使用一個伙伴進程(或者說是協同進程)來幫忙處理注冊的任務
DNS
SkyDNS
https://github.com/skynetservices/skydns
SkyDNS docker鏡像 https://hub.docker.com/r/skynetservices/skydns/
skydock (SkyDNS集成到Docker的方案,目前只能用在一台Docker宿主機上) https://github.com/crosbymichael/skydock
weave-dns (允許跨多台Docker宿主機,但必須在專有的weave覆蓋網絡上使用)
https://github.com/weaveworks/ ... vedns
Zookeeper
znode
Apache Curator(zookeeper客戶端庫) http://curator.apache.orgX17X 入門文檔 http://tomaszdziurko.pl/2014/0 ... cing/
etcd
生產環境集群設置方案 https://coreos.com/os/docs/lat ... .html
安全模型 https://github.com/coreos/etcd ... ty.md
Docker Service Discovery Using Etcd and Haproxy http://jasonwilder.com/blog/20 ... very/
consul 分布式鍵值存儲、分布式監控工具、DNS服務器
https://www.consul.io/docs/index.html
serf https://www.serfdom.io
Web UI https://github.com/hashicorp/c ... ME.md
registrator https://github.com/gliderlabs/registrator
鏡像 https://registry.hub.docker.co ... ator/
Eureka
https://github.com/Netflix/eureka
https://github.com/Netflix/eur ... rview
Netflix http://techblog.netflix.com
http://netflix.github.io
Smartstack 技術無關性,不需要用戶編寫任何額外的應用代碼,可被部署到祼機、虛擬機或Docker容器里
包含zookeeper、haproxy以及
Nerve 監控機器和服務的健康狀況 https://github.com/airbnb/nerve
Synapse 服務發現 https://github.com/airbnb/synapse
nsqlookupd 在大規模基礎設施里運行分布式消息隊列的解決方案
http://nsq.io/components/nsqlookupd.html
http://nsq.io/components/nsqd.html
日志
在其它容器一側收集日志
docker run -v /logs --name redis registry/redis
docker run -d --volumes-from redis --name log_collector registry/logcollector
監控
Datadog https://www.datadoghq.com/blog ... adog/
Docker Python API docker-py https://github.com/docker/docker-py
Docker 遠程API https://docs.docker.com/refere ... _api/
Docker集群管理系統Shipyard https://github.com/shipyard/shipyard
docker ps
docker stats