© 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

PPT
From docker hub to bluemix catalog
PPTX
Retrive&amp;rank
PPT
Bluemix Node-Red Part II
PPT
Bluemix node red-part iii
PPT
Open whisk quick start guide
PPT
Bluemix Node-Red Part I
PDF
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
PPTX
Docker 淺入淺出
From docker hub to bluemix catalog
Retrive&amp;rank
Bluemix Node-Red Part II
Bluemix node red-part iii
Open whisk quick start guide
Bluemix Node-Red Part I
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
Docker 淺入淺出

What's hot (20)

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

Viewers also liked (20)

PPT
Bluemix hadoop beginners Guide part I
PPT
Investment advisor with bluemix trade off analysis
PPTX
Design Portfolio
PDF
Building distribution packages with Docker
PDF
Introduction to Drupal (中文)
PDF
那些在NTUST.CC背後。你所不知道的故事
PPT
Connect to blumix docker container with putty
PDF
Open source based container solution in Azure - May Docker Meetup
PPT
Create docker image with bluemix dev ops
PDF
Power Systems Projects in Research
PDF
Docker Container Cloud
PDF
愛樂工程師
PDF
IBM Container BluemixでDockerを使ってみる
PPTX
A Dive Into Containers and Docker
PPTX
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
PDF
利用 iOS App 技術創業的 13 個方法
PDF
IBM Containers- Bluemix
PDF
Project Humix overview
PPTX
Facebook粉絲專頁課程
PPTX
使用 Visual Studio Code 建構 JavaScript 應用程式
Bluemix hadoop beginners Guide part I
Investment advisor with bluemix trade off analysis
Design Portfolio
Building distribution packages with Docker
Introduction to Drupal (中文)
那些在NTUST.CC背後。你所不知道的故事
Connect to blumix docker container with putty
Open source based container solution in Azure - May Docker Meetup
Create docker image with bluemix dev ops
Power Systems Projects in Research
Docker Container Cloud
愛樂工程師
IBM Container BluemixでDockerを使ってみる
A Dive Into Containers and Docker
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
利用 iOS App 技術創業的 13 個方法
IBM Containers- Bluemix
Project Humix overview
Facebook粉絲專頁課程
使用 Visual Studio Code 建構 JavaScript 應用程式
Ad

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

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

More from Joseph Chang (9)

PPT
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configration
PPT
Run windows vm on bluemix
PPT
Connect to blumix vm with vnc
PPT
Connect to blumix vm with putty
PPT
Using java to access bluemix object storage v2
PPTX
Bluemix iot demo
PPT
Bluemix u steam
PPT
Bluemix iot with intel galileo
PPTX
IBM Bluemix introduction
Jcconf 2015 Taipei -- Bluemix java liberty -auto-configration
Run windows vm on bluemix
Connect to blumix vm with vnc
Connect to blumix vm with putty
Using java to access bluemix object storage v2
Bluemix iot demo
Bluemix u steam
Bluemix iot with intel galileo
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