SlideShare a Scribd company logo
© 2014 IBM Corporation
Create
Bluemix Docker Container
with REST API
Joseph Chang
Senior IT Specialist
IBM Cloud Group
Document number
© 2014 IBM Corporation2
If you are new to Bluemix Docker Container, please start from here:
https://console.ng.bluemix.net/docs/containers/container_index.html
© 2014 IBM Corporation3
http://ccsapi-doc.mybluemix.net
由此網址可以查
看以 Swagger
方式呈現的
Bluemix
Container API,
© 2014 IBM Corporation
Get X-Auth-Token and X-Auth-Project-Id
4
© 2014 IBM Corporation
取得 X-Auth-Token 及 X-Auth-Project-Id
5
呼叫所有的 Container API
都需要這兩個參數 , 我們
可以用 curl 取得 , ( 不需
要安裝 cf command line
tool )
© 2014 IBM Corporation
利用 curl 取得 X-Auth-Token 及 X-Auth-Project-Id
6
首先呼叫此 API 以取得
正確的 UAALoginServer
端口位置。
curl -G http://api.ng.bluemix.net/info
{"name":"Bluemix",
"build":"235018",
"support":"http://ibm.biz/bluemix-supportinfo",
"version":0,
"description":"IBM Bluemix",
"authorization_endpoint":"https://login.ng.bluemix.net/UAALoginServerWAR",
"token_endpoint":"https://uaa.ng.bluemix.net",
"allow_debug":true}
Request:
Response:
© 2014 IBM Corporation
利用 curl 取得 X-Auth-Token
7
呼叫此 API 以取得 Auth-
Token 。
除了 username 及 password
的部份為你的 Bluemix 帳密。
其餘部份照抄 , 勿更動。
curl -i -H "Authorization:Basic Y2Y6" -d "grant_type=password&username=<bluemix id>&password=<password>"
https://login.ng.bluemix.net/UAALoginServerWAR/oauth/token
Request:
Response:
Response 如下,黃色框線
” access_token” 欄位中的值即為
我們所需的
X-Auth-Token 。
Ex:
© 2014 IBM Corporation
利用 curl 取得 X-Auth-Project-Id
8
X-Auth-Project-Id 的值
為 space_id ,為了取得
space_id, 我們需要先取
得 organization_id
。
X-Auth-Project-Id = <space_id>
Get <space_id>
Get <Organization_id>
© 2014 IBM Corporation
利用 curl 取得 X-Auth-Project-Id
Step 1: Get Organization_Id
9
Request:
Response:
curl -H "Authorization: bearer <access_token>" -G http://api.ng.bluemix.net/v2/organizations
Ex:
從回傳結果中取
得 space_url 。
呼叫此 API 以取得
Organization 資訊 , 請選擇目
標 container 所屬的 Org 。
圖中數字經亂數化
過 , 非真實
Org_id 。
© 2014 IBM Corporation
利用 curl 取得 X-Auth-Project-Id
Step2: Get Space_Id
10
Request:
Response:
curl -H "Authorization: bearer <access_token>" -G http://api.ng.bluemix.net/v2/organizations/<org_id>/spaces
Ex:
Space id 的值不會變動
, 所以你也可以透過 cf
command 或 bluemix
UI 取得後記下來。
呼叫此 API 以取得 Space 資
訊 , 請選擇目標 container 所
屬的 Space 。
Space 的 guid ( 黃色框
線 ) 即為我們所需之 X-
Auth-Project-id 。
© 2014 IBM Corporation
Test Calling API
11
© 2014 IBM Corporation
Test it, 測試一下
12
填入 X-Auth-Token
及 X-Auth-Project-
Id, ,然 後按 Try it
out!
此工具無法正常執行
! 但是可以協助組合
出正確的 curl 命令
© 2014 IBM Corporation
Test it, 測試一下
13
執行結果如下 , 請複
製 Curl 的內容 , 貼
到命令列中執行
© 2014 IBM Corporation
Test it, 測試一下
14
執行結果如下
如果看到 [{“message”:
“The size of an image
reported by IBM
Container….. 表示成功
© 2014 IBM Corporation
Create Container with API
15
© 2014 IBM Corporation
了解 Create Container 的 REST API 名稱及參數
16
使用這個 API 來
Create Container
© 2014 IBM Corporation
了解 Create Container 的 REST API 名稱及參數
17
Create Container 需
要這四個參數 , 其中
的 Param 是一個複
雜的 JSON
structure, 需要特別
說明。
請點選此處。
© 2014 IBM Corporation
了解 Create Container 的 REST API 名稱及參數
18
點選後會自
動帶入以上
預設內容。
Param 參數 值 備註
Memory 256
Env [“ENV1=TEST1] 格式正確即可 , 在此不會直正用到
Cmd Remove it 與 liberty server 搭配時 , 請刪除此參數 , 以
免影響 Server 起動
Image “registry.ng.bluemix.net/
ibmliberty:latest”
此 Image 帶有 liberty server, 容易觀察結果
是否正確
ExposedPorts [“9080”,”9443”]
HostConfig 參考下表
BluemixApp “” 填入的 cf app 必須存在 , 否則否有錯誤
, 初次測試時建議留空白
Volumes Remove it 填入值不正確會導致 “ The container could
not be created because the volume format
was invalid”
NumberCpus 1
Cpuset “”
HosConfig 參數 值 備註
PortBindings [“9080”,”9443”]
Links Remove it !! 填入值不正確時會導致 “ list index out of
range"
Binds Remove it !! 填入值不正確會導致 “ The container could
not be created because the volume
format was invalid”
ExtraHosts Remove it !! 填入值不正確會導致 container 建立時
crash
© 2014 IBM Corporation
由 Swagger 產生 Create Container 的命令
19
按下 try it out
可產生 curl 指令。
最終參數如左 , 別
忘了填入 X-
Auth-Token 及
X-Auth-Project-
Id 。
© 2014 IBM Corporation
在命令列中執行 create container API
20
看到此訊息表示
create container
指令已被執行。
© 2014 IBM Corporation
The container created by REST API is running !!
21
© 2014 IBM Corporation
Thank you
22
Take me to Bluemix
Click Here
Ad

More Related Content

What's hot (20)

Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final
Paul Chao
 
Docker Build
Docker BuildDocker Build
Docker Build
Miles Chou
 
MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎
Colin Charles
 
twMVC#26 | Redis資料型別與場景的連結
twMVC#26 | Redis資料型別與場景的連結twMVC#26 | Redis資料型別與場景的連結
twMVC#26 | Redis資料型別與場景的連結
twMVC
 
20220224台中演講k8s
20220224台中演講k8s20220224台中演講k8s
20220224台中演講k8s
chabateryuhlin
 
開發人員不可不知的 Windows Container 容器技術預覽
開發人員不可不知的 Windows Container 容器技術預覽開發人員不可不知的 Windows Container 容器技術預覽
開發人員不可不知的 Windows Container 容器技術預覽
Will Huang
 
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
Bo-Yi Wu
 
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
Will Huang
 
iOS Hotfix
iOS HotfixiOS Hotfix
iOS Hotfix
Abby Lai
 
淺談 Groovy 與 Gradle
淺談 Groovy 與 Gradle淺談 Groovy 與 Gradle
淺談 Groovy 與 Gradle
Justin Lin
 
AWS EC2 for beginner
AWS EC2 for beginnerAWS EC2 for beginner
AWS EC2 for beginner
azole Lai
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
Wei Sun
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_final
Wei Sun
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門
azole Lai
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用
謝 宗穎
 
twMVC#36.NetCore 3快速看一波
twMVC#36.NetCore 3快速看一波twMVC#36.NetCore 3快速看一波
twMVC#36.NetCore 3快速看一波
twMVC
 
Asp.net 5 新功能與變革
Asp.net 5 新功能與變革Asp.net 5 新功能與變革
Asp.net 5 新功能與變革
Gelis Wu
 
rebar erlang 2
rebar erlang 2rebar erlang 2
rebar erlang 2
致远 郑
 
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIStwMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC
 
Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final
Paul Chao
 
MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎
Colin Charles
 
twMVC#26 | Redis資料型別與場景的連結
twMVC#26 | Redis資料型別與場景的連結twMVC#26 | Redis資料型別與場景的連結
twMVC#26 | Redis資料型別與場景的連結
twMVC
 
20220224台中演講k8s
20220224台中演講k8s20220224台中演講k8s
20220224台中演講k8s
chabateryuhlin
 
開發人員不可不知的 Windows Container 容器技術預覽
開發人員不可不知的 Windows Container 容器技術預覽開發人員不可不知的 Windows Container 容器技術預覽
開發人員不可不知的 Windows Container 容器技術預覽
Will Huang
 
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
Bo-Yi Wu
 
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
Will Huang
 
iOS Hotfix
iOS HotfixiOS Hotfix
iOS Hotfix
Abby Lai
 
淺談 Groovy 與 Gradle
淺談 Groovy 與 Gradle淺談 Groovy 與 Gradle
淺談 Groovy 與 Gradle
Justin Lin
 
AWS EC2 for beginner
AWS EC2 for beginnerAWS EC2 for beginner
AWS EC2 for beginner
azole Lai
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
Wei Sun
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_final
Wei Sun
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門
azole Lai
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用
謝 宗穎
 
twMVC#36.NetCore 3快速看一波
twMVC#36.NetCore 3快速看一波twMVC#36.NetCore 3快速看一波
twMVC#36.NetCore 3快速看一波
twMVC
 
Asp.net 5 新功能與變革
Asp.net 5 新功能與變革Asp.net 5 新功能與變革
Asp.net 5 新功能與變革
Gelis Wu
 
rebar erlang 2
rebar erlang 2rebar erlang 2
rebar erlang 2
致远 郑
 
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIStwMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC
 

Viewers also liked (20)

Bluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part IBluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part I
Joseph Chang
 
Investment advisor with bluemix trade off analysis
Investment advisor with bluemix trade off analysisInvestment advisor with bluemix trade off analysis
Investment advisor with bluemix trade off analysis
Joseph Chang
 
Design Portfolio
Design PortfolioDesign Portfolio
Design Portfolio
Colorcode Global
 
Building distribution packages with Docker
Building distribution packages with DockerBuilding distribution packages with Docker
Building distribution packages with Docker
Bruno Cornec
 
Introduction to Drupal (中文)
Introduction to Drupal (中文)Introduction to Drupal (中文)
Introduction to Drupal (中文)
Hana Chang
 
那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事
Yi-Feng Xie
 
Connect to blumix docker container with putty
Connect to blumix docker container with puttyConnect to blumix docker container with putty
Connect to blumix docker container with putty
Joseph Chang
 
Open source based container solution in Azure - May Docker Meetup
Open source based container solution in Azure - May Docker MeetupOpen source based container solution in Azure - May Docker Meetup
Open source based container solution in Azure - May Docker Meetup
Wiredcraft
 
Create docker image with bluemix dev ops
Create docker image with bluemix dev opsCreate docker image with bluemix dev ops
Create docker image with bluemix dev ops
Joseph Chang
 
Power Systems Projects in Research
Power Systems Projects in ResearchPower Systems Projects in Research
Power Systems Projects in Research
Daniel Krook
 
Docker Container Cloud
Docker Container CloudDocker Container Cloud
Docker Container Cloud
Daniel Krook
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
Tom Chen
 
IBM Container BluemixでDockerを使ってみる
IBM Container BluemixでDockerを使ってみるIBM Container BluemixでDockerを使ってみる
IBM Container BluemixでDockerを使ってみる
Hideaki Tokida
 
A Dive Into Containers and Docker
A Dive Into Containers and DockerA Dive Into Containers and Docker
A Dive Into Containers and Docker
Matthew Farina
 
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
Edge 2016 Session 1886  Building your own docker container cloud on ibm power...Edge 2016 Session 1886  Building your own docker container cloud on ibm power...
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
Yong Feng
 
利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法
彼得潘 Pan
 
IBM Containers- Bluemix
IBM Containers- BluemixIBM Containers- Bluemix
IBM Containers- Bluemix
Virginia Fernandez
 
Project Humix overview
Project Humix overviewProject Humix overview
Project Humix overview
Jeffrey Liu
 
Facebook粉絲專頁課程
Facebook粉絲專頁課程Facebook粉絲專頁課程
Facebook粉絲專頁課程
Norika
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式
Will Huang
 
Bluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part IBluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part I
Joseph Chang
 
Investment advisor with bluemix trade off analysis
Investment advisor with bluemix trade off analysisInvestment advisor with bluemix trade off analysis
Investment advisor with bluemix trade off analysis
Joseph Chang
 
Building distribution packages with Docker
Building distribution packages with DockerBuilding distribution packages with Docker
Building distribution packages with Docker
Bruno Cornec
 
Introduction to Drupal (中文)
Introduction to Drupal (中文)Introduction to Drupal (中文)
Introduction to Drupal (中文)
Hana Chang
 
那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事
Yi-Feng Xie
 
Connect to blumix docker container with putty
Connect to blumix docker container with puttyConnect to blumix docker container with putty
Connect to blumix docker container with putty
Joseph Chang
 
Open source based container solution in Azure - May Docker Meetup
Open source based container solution in Azure - May Docker MeetupOpen source based container solution in Azure - May Docker Meetup
Open source based container solution in Azure - May Docker Meetup
Wiredcraft
 
Create docker image with bluemix dev ops
Create docker image with bluemix dev opsCreate docker image with bluemix dev ops
Create docker image with bluemix dev ops
Joseph Chang
 
Power Systems Projects in Research
Power Systems Projects in ResearchPower Systems Projects in Research
Power Systems Projects in Research
Daniel Krook
 
Docker Container Cloud
Docker Container CloudDocker Container Cloud
Docker Container Cloud
Daniel Krook
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
Tom Chen
 
IBM Container BluemixでDockerを使ってみる
IBM Container BluemixでDockerを使ってみるIBM Container BluemixでDockerを使ってみる
IBM Container BluemixでDockerを使ってみる
Hideaki Tokida
 
A Dive Into Containers and Docker
A Dive Into Containers and DockerA Dive Into Containers and Docker
A Dive Into Containers and Docker
Matthew Farina
 
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
Edge 2016 Session 1886  Building your own docker container cloud on ibm power...Edge 2016 Session 1886  Building your own docker container cloud on ibm power...
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
Yong Feng
 
利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法
彼得潘 Pan
 
Project Humix overview
Project Humix overviewProject Humix overview
Project Humix overview
Jeffrey Liu
 
Facebook粉絲專頁課程
Facebook粉絲專頁課程Facebook粉絲專頁課程
Facebook粉絲專頁課程
Norika
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式
Will Huang
 
Ad

Similar to Create to blumix docker container with rest api (20)

Bluemix Connect & Compose
Bluemix Connect & ComposeBluemix Connect & Compose
Bluemix Connect & Compose
Chang-Yen Huang
 
容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中
Andrew Wu
 
Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探
Gelis Wu
 
Docker open stack
Docker open stackDocker open stack
Docker open stack
Guangya Liu
 
Web server and_cgi
Web server and_cgiWeb server and_cgi
Web server and_cgi
xu liwei
 
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Jeff Chu
 
[email protected]
Clipper@datacon.2019.twClipper@datacon.2019.tw
[email protected]
Wei-Yu Chen
 
容器式基礎架構介紹
容器式基礎架構介紹容器式基礎架構介紹
容器式基礎架構介紹
Philip Zheng
 
ES5 introduction
ES5 introductionES5 introduction
ES5 introduction
otakustay
 
以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App
Ben Lue
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接
Renaun Erickson
 
Rpc原理与实现
Rpc原理与实现Rpc原理与实现
Rpc原理与实现
wavefly
 
企業導入容器經驗分享與開源技能培養
企業導入容器經驗分享與開源技能培養企業導入容器經驗分享與開源技能培養
企業導入容器經驗分享與開源技能培養
Philip Zheng
 
Cloud Foundry Introduction
Cloud Foundry IntroductionCloud Foundry Introduction
Cloud Foundry Introduction
家弘 周
 
91APP: 從 "零" 開始的 DevOps
91APP: 從 "零" 開始的 DevOps91APP: 從 "零" 開始的 DevOps
91APP: 從 "零" 開始的 DevOps
Andrew Wu
 
利用Signalr打造即時通訊@Tech day geek
利用Signalr打造即時通訊@Tech day geek利用Signalr打造即時通訊@Tech day geek
利用Signalr打造即時通訊@Tech day geek
Johnson Gau
 
HTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 appHTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 app
Ben Lue
 
面向对象设计七大原则
面向对象设计七大原则面向对象设计七大原则
面向对象设计七大原则
zoorz
 
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
Wade Huang
 
Bluemix Connect & Compose
Bluemix Connect & ComposeBluemix Connect & Compose
Bluemix Connect & Compose
Chang-Yen Huang
 
容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中
Andrew Wu
 
Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探
Gelis Wu
 
Docker open stack
Docker open stackDocker open stack
Docker open stack
Guangya Liu
 
Web server and_cgi
Web server and_cgiWeb server and_cgi
Web server and_cgi
xu liwei
 
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Jeff Chu
 
容器式基礎架構介紹
容器式基礎架構介紹容器式基礎架構介紹
容器式基礎架構介紹
Philip Zheng
 
ES5 introduction
ES5 introductionES5 introduction
ES5 introduction
otakustay
 
以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App
Ben Lue
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接
Renaun Erickson
 
Rpc原理与实现
Rpc原理与实现Rpc原理与实现
Rpc原理与实现
wavefly
 
企業導入容器經驗分享與開源技能培養
企業導入容器經驗分享與開源技能培養企業導入容器經驗分享與開源技能培養
企業導入容器經驗分享與開源技能培養
Philip Zheng
 
Cloud Foundry Introduction
Cloud Foundry IntroductionCloud Foundry Introduction
Cloud Foundry Introduction
家弘 周
 
91APP: 從 "零" 開始的 DevOps
91APP: 從 "零" 開始的 DevOps91APP: 從 "零" 開始的 DevOps
91APP: 從 "零" 開始的 DevOps
Andrew Wu
 
利用Signalr打造即時通訊@Tech day geek
利用Signalr打造即時通訊@Tech day geek利用Signalr打造即時通訊@Tech day geek
利用Signalr打造即時通訊@Tech day geek
Johnson Gau
 
HTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 appHTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 app
Ben Lue
 
面向对象设计七大原则
面向对象设计七大原则面向对象设计七大原则
面向对象设计七大原则
zoorz
 
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
Wade Huang
 
Ad

More from Joseph Chang (9)

Jcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configrationJcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Joseph Chang
 
Run windows vm on bluemix
Run windows vm on bluemixRun windows vm on bluemix
Run windows vm on bluemix
Joseph Chang
 
Connect to blumix vm with vnc
Connect to blumix vm with vncConnect to blumix vm with vnc
Connect to blumix vm with vnc
Joseph Chang
 
Connect to blumix vm with putty
Connect to blumix vm with puttyConnect to blumix vm with putty
Connect to blumix vm with putty
Joseph Chang
 
Using java to access bluemix object storage v2
Using java to access bluemix object storage v2Using java to access bluemix object storage v2
Using java to access bluemix object storage v2
Joseph Chang
 
Bluemix iot demo
Bluemix iot demoBluemix iot demo
Bluemix iot demo
Joseph Chang
 
Bluemix u steam
Bluemix u steamBluemix u steam
Bluemix u steam
Joseph Chang
 
Bluemix iot with intel galileo
Bluemix iot with intel galileoBluemix iot with intel galileo
Bluemix iot with intel galileo
Joseph Chang
 
IBM Bluemix introduction
IBM Bluemix introductionIBM Bluemix introduction
IBM Bluemix introduction
Joseph Chang
 
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configrationJcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Joseph Chang
 
Run windows vm on bluemix
Run windows vm on bluemixRun windows vm on bluemix
Run windows vm on bluemix
Joseph Chang
 
Connect to blumix vm with vnc
Connect to blumix vm with vncConnect to blumix vm with vnc
Connect to blumix vm with vnc
Joseph Chang
 
Connect to blumix vm with putty
Connect to blumix vm with puttyConnect to blumix vm with putty
Connect to blumix vm with putty
Joseph Chang
 
Using java to access bluemix object storage v2
Using java to access bluemix object storage v2Using java to access bluemix object storage v2
Using java to access bluemix object storage v2
Joseph Chang
 
Bluemix iot with intel galileo
Bluemix iot with intel galileoBluemix iot with intel galileo
Bluemix iot with intel galileo
Joseph Chang
 
IBM Bluemix introduction
IBM Bluemix introductionIBM Bluemix introduction
IBM Bluemix introduction
Joseph Chang
 

Create to blumix docker container with rest api

  • 1. © 2014 IBM Corporation Create Bluemix Docker Container with REST API Joseph Chang Senior IT Specialist IBM Cloud Group Document number
  • 2. © 2014 IBM Corporation2 If you are new to Bluemix Docker Container, please start from here: https://console.ng.bluemix.net/docs/containers/container_index.html
  • 3. © 2014 IBM Corporation3 http://ccsapi-doc.mybluemix.net 由此網址可以查 看以 Swagger 方式呈現的 Bluemix Container API,
  • 4. © 2014 IBM Corporation Get X-Auth-Token and X-Auth-Project-Id 4
  • 5. © 2014 IBM Corporation 取得 X-Auth-Token 及 X-Auth-Project-Id 5 呼叫所有的 Container API 都需要這兩個參數 , 我們 可以用 curl 取得 , ( 不需 要安裝 cf command line tool )
  • 6. © 2014 IBM Corporation 利用 curl 取得 X-Auth-Token 及 X-Auth-Project-Id 6 首先呼叫此 API 以取得 正確的 UAALoginServer 端口位置。 curl -G http://api.ng.bluemix.net/info {"name":"Bluemix", "build":"235018", "support":"http://ibm.biz/bluemix-supportinfo", "version":0, "description":"IBM Bluemix", "authorization_endpoint":"https://login.ng.bluemix.net/UAALoginServerWAR", "token_endpoint":"https://uaa.ng.bluemix.net", "allow_debug":true} Request: Response:
  • 7. © 2014 IBM Corporation 利用 curl 取得 X-Auth-Token 7 呼叫此 API 以取得 Auth- Token 。 除了 username 及 password 的部份為你的 Bluemix 帳密。 其餘部份照抄 , 勿更動。 curl -i -H "Authorization:Basic Y2Y6" -d "grant_type=password&username=<bluemix id>&password=<password>" https://login.ng.bluemix.net/UAALoginServerWAR/oauth/token Request: Response: Response 如下,黃色框線 ” access_token” 欄位中的值即為 我們所需的 X-Auth-Token 。 Ex:
  • 8. © 2014 IBM Corporation 利用 curl 取得 X-Auth-Project-Id 8 X-Auth-Project-Id 的值 為 space_id ,為了取得 space_id, 我們需要先取 得 organization_id 。 X-Auth-Project-Id = <space_id> Get <space_id> Get <Organization_id>
  • 9. © 2014 IBM Corporation 利用 curl 取得 X-Auth-Project-Id Step 1: Get Organization_Id 9 Request: Response: curl -H "Authorization: bearer <access_token>" -G http://api.ng.bluemix.net/v2/organizations Ex: 從回傳結果中取 得 space_url 。 呼叫此 API 以取得 Organization 資訊 , 請選擇目 標 container 所屬的 Org 。 圖中數字經亂數化 過 , 非真實 Org_id 。
  • 10. © 2014 IBM Corporation 利用 curl 取得 X-Auth-Project-Id Step2: Get Space_Id 10 Request: Response: curl -H "Authorization: bearer <access_token>" -G http://api.ng.bluemix.net/v2/organizations/<org_id>/spaces Ex: Space id 的值不會變動 , 所以你也可以透過 cf command 或 bluemix UI 取得後記下來。 呼叫此 API 以取得 Space 資 訊 , 請選擇目標 container 所 屬的 Space 。 Space 的 guid ( 黃色框 線 ) 即為我們所需之 X- Auth-Project-id 。
  • 11. © 2014 IBM Corporation Test Calling API 11
  • 12. © 2014 IBM Corporation Test it, 測試一下 12 填入 X-Auth-Token 及 X-Auth-Project- Id, ,然 後按 Try it out! 此工具無法正常執行 ! 但是可以協助組合 出正確的 curl 命令
  • 13. © 2014 IBM Corporation Test it, 測試一下 13 執行結果如下 , 請複 製 Curl 的內容 , 貼 到命令列中執行
  • 14. © 2014 IBM Corporation Test it, 測試一下 14 執行結果如下 如果看到 [{“message”: “The size of an image reported by IBM Container….. 表示成功
  • 15. © 2014 IBM Corporation Create Container with API 15
  • 16. © 2014 IBM Corporation 了解 Create Container 的 REST API 名稱及參數 16 使用這個 API 來 Create Container
  • 17. © 2014 IBM Corporation 了解 Create Container 的 REST API 名稱及參數 17 Create Container 需 要這四個參數 , 其中 的 Param 是一個複 雜的 JSON structure, 需要特別 說明。 請點選此處。
  • 18. © 2014 IBM Corporation 了解 Create Container 的 REST API 名稱及參數 18 點選後會自 動帶入以上 預設內容。 Param 參數 值 備註 Memory 256 Env [“ENV1=TEST1] 格式正確即可 , 在此不會直正用到 Cmd Remove it 與 liberty server 搭配時 , 請刪除此參數 , 以 免影響 Server 起動 Image “registry.ng.bluemix.net/ ibmliberty:latest” 此 Image 帶有 liberty server, 容易觀察結果 是否正確 ExposedPorts [“9080”,”9443”] HostConfig 參考下表 BluemixApp “” 填入的 cf app 必須存在 , 否則否有錯誤 , 初次測試時建議留空白 Volumes Remove it 填入值不正確會導致 “ The container could not be created because the volume format was invalid” NumberCpus 1 Cpuset “” HosConfig 參數 值 備註 PortBindings [“9080”,”9443”] Links Remove it !! 填入值不正確時會導致 “ list index out of range" Binds Remove it !! 填入值不正確會導致 “ The container could not be created because the volume format was invalid” ExtraHosts Remove it !! 填入值不正確會導致 container 建立時 crash
  • 19. © 2014 IBM Corporation 由 Swagger 產生 Create Container 的命令 19 按下 try it out 可產生 curl 指令。 最終參數如左 , 別 忘了填入 X- Auth-Token 及 X-Auth-Project- Id 。
  • 20. © 2014 IBM Corporation 在命令列中執行 create container API 20 看到此訊息表示 create container 指令已被執行。
  • 21. © 2014 IBM Corporation The container created by REST API is running !! 21
  • 22. © 2014 IBM Corporation Thank you 22 Take me to Bluemix Click Here