Mees Kluivers Mees Kluivers - 1 month ago 6
JSON Question

"forcePullImage" param gets set to 'false'

I am trying to build a docker image with Marathon, however when I use this configuration, the "forcePullImage" param gets set to 'false'

{
"id": "name",
"mem": 1024,
"cpus": 0.5,
"instances": 1,
"container": {
"type": "DOCKER",
"volumes": [
{
"containerPath": "/etc/localtime",
"hostPath": "/etc/localtime",
"mode": "RO"
}
],
"docker": {
"image": "dockerimage",
"network": "BRIDGE",
"portMappings": [ {
"containerPort": 8080,
"hostPort": 0,
"servicePort": [PORTNUMBER],
"protocol": "tcp",
"name": "name"
}],
"parameters": [{ "key": "name", "value": "name" }]
},
"forcePullImage": true
},
"healthChecks": [
{
"path": "~/check/",
"portIndex": 0,
"protocol": "HTTP",
"gracePeriodSeconds": 10,
"intervalSeconds": 2,
"timeoutSeconds": 10,
"maxConsecutiveFailures": 10
}],
"labels":{
"HAPROXY_GROUP":"external"
}
}


When it is finally build in the marathon enviroment the config file gets set to this:

{
"id": "name",
"mem": 1024,
"cpus": 0.5,
"instances": 1,
"container": {
"type": "DOCKER",
"volumes": [
{
"containerPath": "/etc/localtime",
"hostPath": "/etc/localtime",
"mode": "RO"
}
],
"docker": {
"image": "dockerimage",
"network": "BRIDGE",
"portMappings": [ {
"containerPort": 8080,
"hostPort": 0,
"servicePort": [PORTNUMBER],
"protocol": "tcp",
"name": "name"
}],
"parameters": [{ "key": "name", "value": "name" }]
},
"forcePullImage": false
},
"healthChecks": [
{
"path": "~/check/",
"portIndex": 0,
"protocol": "HTTP",
"gracePeriodSeconds": 10,
"intervalSeconds": 2,
"timeoutSeconds": 10,
"maxConsecutiveFailures": 10
}],
"labels":{
"HAPROXY_GROUP":"external"
}
}


After it is build I have to manually change the 'false' param to 'true' and after that it actually works, but why is it getting set to false when adding it to marathon and how can I fix this problem?

Answer

The Marathon app spec you posted is in fact invalid. If you look at the schema you see that forcePullImage has to be a child of the docker field (not the container field as in your example). The correct usage would be:

"docker": {
  "image": "dockerimage",
  "forcePullImage": false,
  ...
}