SlideShare a Scribd company logo
1 of 22
© 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

More Related Content

What's hot

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
 
rebar erlang 2
rebar erlang 2rebar erlang 2
rebar erlang 2
致远 郑
 

What's hot (20)

Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final
 
Docker Build
Docker BuildDocker Build
Docker Build
 
MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎MariaDB: 新兴的开源大数据引擎
MariaDB: 新兴的开源大数据引擎
 
twMVC#26 | Redis資料型別與場景的連結
twMVC#26 | Redis資料型別與場景的連結twMVC#26 | Redis資料型別與場景的連結
twMVC#26 | Redis資料型別與場景的連結
 
20220224台中演講k8s
20220224台中演講k8s20220224台中演講k8s
20220224台中演講k8s
 
開發人員不可不知的 Windows Container 容器技術預覽
開發人員不可不知的 Windows Container 容器技術預覽開發人員不可不知的 Windows Container 容器技術預覽
開發人員不可不知的 Windows Container 容器技術預覽
 
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
 
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
 
iOS Hotfix
iOS HotfixiOS Hotfix
iOS Hotfix
 
淺談 Groovy 與 Gradle
淺談 Groovy 與 Gradle淺談 Groovy 與 Gradle
淺談 Groovy 與 Gradle
 
AWS EC2 for beginner
AWS EC2 for beginnerAWS EC2 for beginner
AWS EC2 for beginner
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_final
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用
 
twMVC#36.NetCore 3快速看一波
twMVC#36.NetCore 3快速看一波twMVC#36.NetCore 3快速看一波
twMVC#36.NetCore 3快速看一波
 
Asp.net 5 新功能與變革
Asp.net 5 新功能與變革Asp.net 5 新功能與變革
Asp.net 5 新功能與變革
 
Openstack网络规划
Openstack网络规划Openstack网络规划
Openstack网络规划
 
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
 

Viewers also liked

那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事
Yi-Feng Xie
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
Tom Chen
 

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
 
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
 
Design Portfolio
Design PortfolioDesign Portfolio
Design Portfolio
 
Building distribution packages with Docker
Building distribution packages with DockerBuilding distribution packages with Docker
Building distribution packages with Docker
 
Introduction to Drupal (中文)
Introduction to Drupal (中文)Introduction to Drupal (中文)
Introduction to Drupal (中文)
 
那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事那些在NTUST.CC背後。你所不知道的故事
那些在NTUST.CC背後。你所不知道的故事
 
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
 
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
 
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
 
Power Systems Projects in Research
Power Systems Projects in ResearchPower Systems Projects in Research
Power Systems Projects in Research
 
Docker Container Cloud
Docker Container CloudDocker Container Cloud
Docker Container Cloud
 
愛樂工程師
愛樂工程師愛樂工程師
愛樂工程師
 
IBM Container BluemixでDockerを使ってみる
IBM Container BluemixでDockerを使ってみるIBM Container BluemixでDockerを使ってみる
IBM Container BluemixでDockerを使ってみる
 
A Dive Into Containers and Docker
A Dive Into Containers and DockerA Dive Into Containers and Docker
A Dive Into Containers and Docker
 
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...
 
利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法利用 iOS App 技術創業的 13 個方法
利用 iOS App 技術創業的 13 個方法
 
IBM Containers- Bluemix
IBM Containers- BluemixIBM Containers- Bluemix
IBM Containers- Bluemix
 
Project Humix overview
Project Humix overviewProject Humix overview
Project Humix overview
 
Facebook粉絲專頁課程
Facebook粉絲專頁課程Facebook粉絲專頁課程
Facebook粉絲專頁課程
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式
 

Similar to Create to blumix docker container with rest api

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

Bluemix Connect & Compose
Bluemix Connect & ComposeBluemix Connect & Compose
Bluemix Connect & Compose
 
容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中
 
Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探Asp.net mvc 6 新功能初探
Asp.net mvc 6 新功能初探
 
Docker open stack
Docker open stackDocker open stack
Docker open stack
 
Web server and_cgi
Web server and_cgiWeb server and_cgi
Web server and_cgi
 
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
Windows 與 Azure 的容器旅程 @ Ignite Mini 2016
 
Clipper@datacon.2019.tw
Clipper@datacon.2019.twClipper@datacon.2019.tw
Clipper@datacon.2019.tw
 
容器式基礎架構介紹
容器式基礎架構介紹容器式基礎架構介紹
容器式基礎架構介紹
 
ES5 introduction
ES5 introductionES5 introduction
ES5 introduction
 
以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接
 
Rpc原理与实现
Rpc原理与实现Rpc原理与实现
Rpc原理与实现
 
企業導入容器經驗分享與開源技能培養
企業導入容器經驗分享與開源技能培養企業導入容器經驗分享與開源技能培養
企業導入容器經驗分享與開源技能培養
 
Cloud Foundry Introduction
Cloud Foundry IntroductionCloud Foundry Introduction
Cloud Foundry Introduction
 
91APP: 從 "零" 開始的 DevOps
91APP: 從 "零" 開始的 DevOps91APP: 從 "零" 開始的 DevOps
91APP: 從 "零" 開始的 DevOps
 
利用Signalr打造即時通訊@Tech day geek
利用Signalr打造即時通訊@Tech day geek利用Signalr打造即時通訊@Tech day geek
利用Signalr打造即時通訊@Tech day geek
 
HTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 appHTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 app
 
面向对象设计七大原则
面向对象设计七大原则面向对象设计七大原则
面向对象设计七大原则
 
Exodus2 大局观
Exodus2 大局观Exodus2 大局观
Exodus2 大局观
 
客戶常見問題分享與解決
客戶常見問題分享與解決客戶常見問題分享與解決
客戶常見問題分享與解決
 

More from Joseph Chang

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
 
Run windows vm on bluemix
Run windows vm on bluemixRun windows vm on bluemix
Run windows vm on bluemix
 
Connect to blumix vm with vnc
Connect to blumix vm with vncConnect to blumix vm with vnc
Connect to blumix vm with vnc
 
Connect to blumix vm with putty
Connect to blumix vm with puttyConnect to blumix vm with putty
Connect to blumix vm with putty
 
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
 
Bluemix iot demo
Bluemix iot demoBluemix iot demo
Bluemix iot demo
 
Bluemix u steam
Bluemix u steamBluemix u steam
Bluemix u steam
 
Bluemix iot with intel galileo
Bluemix iot with intel galileoBluemix iot with intel galileo
Bluemix iot with intel galileo
 
IBM Bluemix introduction
IBM Bluemix introductionIBM Bluemix introduction
IBM Bluemix introduction
 

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