2

I am trying to test docker port mapping by specifying parameters in the chronos job definition. The parameters options doesn't seem to take any effect on the docker run.

Job definition as follows:

{
  "schedule": "R0//P",
  "name": "testjob",
  "container": {
    "type": "DOCKER",
    "image": "path_to_image",
    "network": "BRIDGE",
     "parameters" : [
        {"key" : "-p", "value": "8888:4400"}
   ]
},
  "cpus": "4",
  "mem": "512",
  "uris": ["path to dockercfg.tar.gz"],
  "command" : "./command-to-execute"
}

1) Docker run on the node doesn't take parameters into consideration. Any suggestions on the correct way to include parameters as part of docker run will be highly appreciated?

2) The Docker Image I am trying to run has ENTRYPOINT specified in it. So technically, the ENTRYPOINT should run when the docker runs the container. With the way Chronos is set up, I am forced to provide "command" option in the job JSON (skipping command option during job submission throws back error). When the container is actually scheduled on the target node then instead of using the ENTRYPOINT from the dockerfile, it actually tries to run the command specified in the job definition JSON. Can someone provide a way for using Chronos to run ENTRYPOINT instead of command from Chronos job JSON definition? Notes: Setting command to blank doesn't help. ENTRYPOINT can be specified as a command in JSON job definition and that should fix the problem with command. But don't have access to ENTRYPOINT for all the containers.

***Edit 1: Modified question with some more context and clarity

  • Chronos not supporting 'parameters' was a known bug that got fixed in Chronos 2.5.0(https://github.com/mesos/chronos/pull/538). Solution to Issue #2 is provided by Tonsic. – Abhinav Nov 19 '17 at 15:37

2 Answers2

0

You should have a look at the official docs regarding how to run a Docker job.

A docker job takes the same format as a scheduled job or a dependency job and runs on a Docker container. To configure it, an additional container argument is required, which contains a type (required), an image (required), a network mode (optional), mounted volumes (optional) and whether Mesos should always (force)Pull(Image) the latest image before executing or not (optional).

Concerning 1)
There's no way IMHO to set the parameters like you're trying to. Also, port mappings are specified differently (with Marathon), but as I understand the docs it's not possible at all. And probably not necessary for a batch job.

If you want to run longrunning services, use Marathon.

Concerning 2)
Not sure if I understand you correctly, but normally this would be implemented via specifying an ENTRYPOINT in the Dockerfile

Concerning 3)
Not sure if I understand you correctly, but I think you should be able to omit the command property with Docker jobs.

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • Thanks Tobi. Reagarding #2 an #3, I do have ENTRYPOINT in my docker file. With Chronos, I am seeing job submission errors if the command option is skipped in the job definition JSON. So command option seems to be mandatory. When the container runs, it's not taking the ENTRYPOINT in the docker file but trying to execute the command specified in the job JSON. I am looking for a workaround to execute the ENTRYPOINT in dockerfile and not the command specified in the Chronos job JSON. (Note: Keeping command option as blank doesn't help as well) – user1825838 Apr 15 '16 at 16:07
0

To use the docker container entrypoint you must set "shell" false, and command has to be blank. If command is different than blank, chronos will pass it as an argument to the entrypoint. Your json would be like below.

I don't know if you should use the "uris" field, it is deprecated, and, if it is what I think it is, it seems not required anymore to start docker apps.

About the docker parameters, I think the problem is with the key name that you used. It seems you must omit the - symbol. Try as below.

{

 "schedule": "R0//P",
  "name": "testjob",
  "shell": false,
  "container": {
    "type": "DOCKER",
    "image": "path_to_image",
    "network": "BRIDGE",
     "parameters" : [
        {"key" : "p", "value": "8888:4400"}
   ]
  },
  "cpus": "4",
  "mem": "512",
  "command" : ""
}
Tonsic
  • 890
  • 11
  • 15