接上一篇文章:http://blog.csdn.net/rapheler/article/details/52229208
咱们来看一下Marathon跑一个Docker任务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
$
cat
nginx-bridge-2048game.json
{
"id"
:
"/nginx"
,
"cpus"
: 1,
"mem"
: 128,
"disk"
: 0,
"instances"
: 1,
"container"
: {
"type"
:
"DOCKER"
,
"volumes"
: [
{
"containerPath"
:
"/usr/share/nginx/html/"
,
"hostPath"
:
"/home/ibmcloud/2048-master/"
,
"mode"
:
"RO"
}
],
"docker"
: {
"image"
:
"nginx"
,
"network"
:
"BRIDGE"
,
"portMappings"
: [
{
"containerPort"
: 80,
"hostPort"
: 0,
"protocol"
:
"tcp"
,
"servicePort"
: 80,
"labels"
: {}
}
],
"privileged"
:
false
,
"parameters"
: [],
"forcePullImage"
:
false
}
},
"healthChecks"
: [
{
"path"
:
"/"
,
"protocol"
:
"HTTP"
,
"portIndex"
: 0,
"gracePeriodSeconds"
: 120,
"intervalSeconds"
: 30,
"timeoutSeconds"
: 5,
"maxConsecutiveFailures"
: 3,
"ignoreHttp1xx"
:
false
}
],
"portDefinitions"
: [
{
"port"
: 10003,
"protocol"
:
"tcp"
,
"labels"
: {}
}
]
}
|
1
2
3
4
5
6
7
8
9
10
11
12
|
# curl -u username:password -i -H 'Content-Type: application/json' -d@nginx-bridge-2048game.json 192.168.0.33:8080/v2/apps
HTTP
/1
.1 201 Created
Date: Tue, 07 Jun 2016 07:59:17 GMT
X-Marathon-Leader: http:
//192
.168.0.33:8080
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
Location: http:
//192
.168.0.33:8080
/v2/apps/nginx
Content-Type: application
/json
; qs=2
Transfer-Encoding: chunked
Server: Jetty(9.3.z-SNAPSHOT)
{
"id"
:
"/nginx"
,
"cmd"
:null,
"args"
:null,
"user"
:null,
"env"
:{},
"instances"
:1,
"cpus"
:1,
"mem"
:128,
"disk"
:0,
"executor"
:
""
,
"constraints"
:[],
"uris"
:[],
"fetch"
:[],
"storeUrls"
:[],
"ports"
:[80],
"portDefinitions"
:[{
"port"
:80,
"protocol"
:
"tcp"
,
"labels"
:{}}],
"requirePorts"
:
false
,
"backoffSeconds"
:1,
"backoffFactor"
:1.15,
"maxLaunchDelaySeconds"
:3600,
"container"
:{
"type"
:
"DOCKER"
,
"volumes"
:[{
"containerPath"
:
"/usr/share/nginx/html/"
,
"hostPath"
:
"/home/ibmcloud/2048-master/"
,
"mode"
:
"RO"
}],
"docker"
:{
"image"
:
"nginx"
,
"network"
:
"BRIDGE"
,
"portMappings"
:[{
"containerPort"
:80,
"hostPort"
:0,
"servicePort"
:80,
"protocol"
:
"tcp"
,
"labels"
:{}}],
"privileged"
:
false
,
"parameters"
:[],
"forcePullImage"
:
false
}},
"healthChecks"
:[{
"path"
:
"/"
,
"protocol"
:
"HTTP"
,
"portIndex"
:0,
"gracePeriodSeconds"
:120,
"intervalSeconds"
:30,
"timeoutSeconds"
:5,
"maxConsecutiveFailures"
:3,
"ignoreHttp1xx"
:
false
}],
"readinessChecks"
:[],
"dependencies"
:[],
"upgradeStrategy"
:{
"minimumHealthCapacity"
:1,
"maximumOverCapacity"
:1},
"labels"
:{},
"acceptedResourceRoles"
:null,
"ipAddress"
:null,
"version"
:
"2016-06-07T07:59:18.003Z"
,
"residency"
:null,
"tasksStaged"
:0,
"tasksRunning"
:0,
"tasksHealthy"
:0,
"tasksUnhealthy"
:0,
"deployments"
:[{
"id"
:
"c30b9f6e-786c-45bd-9e7e-cc6cc001d91d"
}],
"tasks"
:[]}
#
|
1
2
3
|
$
cat
runapp.sh
#!/bin/bash
curl -i -H
'Content-Type: application/json'
-d@
"$1"
192.168.0.33:8080
/v2/apps
|
1
|
marathon --http_credentials
"username:password"
|