Docker in GCE

Docker專案在GCE上也積極的在發展,可以參考 https://docs.docker.com/installation/google/
透過Google Cloud啟動Docker的Playground Server,可以快速的體驗Docker的功能喲~
首先看看Docker Project提供的Image


$ gcutil --project=google-containers listimages
+--------------------------------------------------------------------------+-------------+--------+

| name                                                                     | deprecation | status |
+--------------------------------------------------------------------------+-------------+--------+
| container-vm-v20140826                                                   |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/centos-cloud/global/images/centos-6-v20140718                   |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/coreos-cloud/global/images/coreos-alpha-423-0-0-v20140828       |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/coreos-cloud/global/images/coreos-beta-410-0-0-v20140825        |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/coreos-cloud/global/images/coreos-stable-367-1-0-v20140724      |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140814  |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/debian-cloud/global/images/debian-7-wheezy-v20140814            |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/opensuse-cloud/global/images/opensuse-13-1-v20140711            |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/rhel-cloud/global/images/rhel-6-v20140718                       |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/suse-cloud/global/images/sles-11-sp3-v20140826                  |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+
| projects/windows-cloud/global/images/windows-server-2008-r2-dc-v20140818 |             | READY  |
+--------------------------------------------------------------------------+-------------+--------+


我們使用最新的Docker Playground來啟動Docker:

gcloud compute instances create docker-playground \
 --image container-vm-v20140826 \
 --image-project google-containers \
 --zone asia-east1-b \
 --machine-type f1-micro

Docker Playground啟動後,我們可以透過gcutil登入Playground Server
然後測試一下Docker的一些指令

$ sudo docker ps

root@docker-playground:~# sudo docker ps
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS              PORTS                    NAMES
3f6b1401fa77        google/cadvisor:latest    "/usr/bin/cadvisor -   7 hours ago         Up 7 hours                                   k8s--cadvisor.1207d44b--cadvisor_-_agent.file--3b3d0248
e73ad4103606        kubernetes/pause:latest   "/pause"               7 hours ago         Up 7 hours          0.0.0.0:4194->8080/tcp   k8s--net.46426d55--cadvisor_-_agent.file--9d94c203

在主機內,Google已經啟動了兩個Container,其中有一個是Google最近積極發展的kubernates
他啟動在8080 port,並對應到主機的4194 port
透過GCE firewall設定打開者個port對外
連線看看:



看起來kubernate與cAdvisor有某個程度的相連,這個界面看起來是為主機的運作狀態,透過這個界面,可以了解Container運作環境的負載狀況...


運行Docker時候,當然在意Performance議題,如果可以用Container替代Production環境,這樣Legacy OS的運作就再也不是夢了!
先在完全不調整環境的狀況下,我們安裝node.js,並運行express基本產出的專案試試:

在運作於GCE的Container上壓測:

下面是直接在GCE上壓測

可以看到效能部分滿逼近裸機(Bare metal)的效能
看來Docker的未來看好喔!