How to start docker jenkins with marathon

696 views
Skip to first unread message

Ankur Chauhan

unread,
Sep 5, 2014, 3:01:15 PM9/5/14
to marathon-...@googlegroups.com
I am trying to run a jenkins server using a docker image but I can't seem to get things going. Has anyone tried this?:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" \
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "aespinosa/jenkins"
    }
  },
  "id": "/jenkins2",
  "instances": "1",
  "cpus": "0.5",
  "mem": "512",
  "disk": "100",
  "ports": [0]
}'

But it keeps failing with

Running from: /opt/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
Registered executor on ec2-54-80-232-82.compute-1.amazonaws.com
Starting task jenkins2.06003ef5-352c-11e4-9629-22000b210ab0
Forked command at 20139
/bin/sh -c exit `docker wait mesos-9614c193-1c7e-4aff-984f-3ff3fb5a567e` 
Jenkins home directory: /jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Command exited with status 2 (pid: 20139)


Ankur Chauhan

unread,
Sep 5, 2014, 3:06:31 PM9/5/14
to marathon-...@googlegroups.com
I also tried as folows:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" \
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "aespinosa/jenkins"
    }
  },
  "id": "/jenkins2",
  "instances": "1",
  "cpus": "0.5",
  "mem": "512",
  "disk": "100",
  "ports": [0],
  "args": [ "--httpPort=$PORT" ]
}'

I0905 19:05:00.427248  9581 exec.cpp:132] Version: 0.20.0
I0905 19:05:00.428508  9603 exec.cpp:206] Executor registered on slave 20140905-030215-1372426762-5050-1787-0
Sep 05, 2014 7:05:00 PM winstone.Logger logInternal
INFO: Beginning extraction from war file
Sep 05, 2014 7:05:01 PM winstone.Logger logInternal
INFO: Winstone shutdown successfully
Sep 05, 2014 7:05:01 PM winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.HttpConnectorFactory
  at winstone.Launcher.spawnListener(Launcher.java:209)
  at winstone.Launcher.<init>(Launcher.java:147)
  at winstone.Launcher.main(Launcher.java:354)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at Main._main(Main.java:293)
  at Main.main(Main.java:98)
Caused by: java.lang.NumberFormatException: For input string: "$PORT"
  at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  at java.lang.Integer.parseInt(Integer.java:481)
  at java.lang.Integer.parseInt(Integer.java:527)
  at winstone.cmdline.Option.intArg(Option.java:293)
  at winstone.cmdline.Option$OInt.get(Option.java:214)
  at winstone.HttpConnectorFactory.start(HttpConnectorFactory.java:27)
  at winstone.Launcher.spawnListener(Launcher.java:207)
  ... 8 more

Dick Davies

unread,
Sep 5, 2014, 3:09:20 PM9/5/14
to marathon-...@googlegroups.com
I can help with that one - it's not expanding the $PORT variable for
you, so it's literally
getting the string $PORT passed in. You could use a shell wrapper so
that environment
var is evaluated for you, perhaps?
> --
> You received this message because you are subscribed to the Google Groups
> "marathon-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to marathon-framew...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ankur Chauhan

unread,
Sep 5, 2014, 4:32:28 PM9/5/14
to marathon-...@googlegroups.com, di...@hellooperator.net
How do I do that? I am pretty new to marathon and mesos so this may be a very n00b question.
But from what I understand, if the variable is not being passed/evaluated a script would also not get the value.

Connor Doyle

unread,
Sep 5, 2014, 5:35:00 PM9/5/14
to Ankur Chauhan, marathon-...@googlegroups.com, Dick Davies
Hi Ankur,

Looking at your Dockerfile, you have defined an entrypoint of: ["java", "-jar", "/opt/jenkins.war"]

"args" are added verbatim to the arguments (in the docker case these come after the ENTRYPOINT).

We have just created an issue whereby when the CommandInfo's shell flag is set to true (as it is when "cmd" is supplied to Marathon) then the Docker containerizer should override the ENTRYPOINT.  See the issue on JIRA here: https://issues.apache.org/jira/browse/MESOS-1770

Putting it all together, for now the workaround is (unfortunately) to create a new Dockerfile that has no entrypoints.  You can run your program using the following Marathon JSON:

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "aespinosa/jenkins"
    }
  },
  "id": "/jenkins2",
  "instances": "1",
  "cpus": "0.5",
  "mem": "512",
  "disk": "100",
  "ports": [0],
  "cmd": "java -jar /opt/jenkins.war --httpPort=$PORT"
}

Once the above issue is fixed, you will be able to run the unmodified Dockerfile in Marathon with the same Marathon JSON.

Sorry for the inconvenience!



To unsubscribe from this group and stop receiving emails from it, send an email to marathon-framew...@googlegroups.com.

Benjamin Staffin

unread,
Sep 5, 2014, 6:17:09 PM9/5/14
to Connor Doyle, Ankur Chauhan, Dick Davies, marathon-...@googlegroups.com
I've been experimenting with various ways of rolling config parameters
and plugins into docker images of jenkins for use with Marathon. It's
nothing revolutionary, but if anyone might find it useful I've got it
shared here: https://github.com/folsom-labs/docker-images/tree/master/jenkins-mesos

The general idea is to parameterize various things via environment
variables, and the runjenkins.sh wrapper script uses xmlstarlet to
adjust the jenkins xml configs before launching jenkins. There's also
various things you can do with groovy scripting at launch; some of
that can be found in the same directory as well.

My marathon job ends up looking like this:

{
"id": "jenkins",
"container": {
"type": "DOCKER",
"docker": {
"image": "folsomlabs/jenkins-mesos"
},
"volumes": []
},
"cpus": 0.5,
"mem": 512,
"instances": 1,
"ports": [0,0,0],
"env": {
"JVM_ARGS": "-Xmx512m",
"mesos_master_url": "zk://zookeeper.example.com:2181/mesos-folsom",
"jenkins_admin_email": "y...@example.com",

Dick Davies

unread,
Sep 6, 2014, 3:35:51 AM9/6/14
to Ankur Chauhan, marathon-...@googlegroups.com
Do it in the docker image, there are a few options mentioned at :

https://goldmann.pl/blog/2014/07/23/customizing-the-configuration-of-the-wildfly-docker-image/

(I swear I found a Go binary designed to be an ENTRYPOINT that did all this from
env. vars, but can't remember its name. It was something like
https://github.com/kelseyhightower/confd
but that one is for etcd variables )
>> > email to marathon-framew...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "marathon-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to marathon-framew...@googlegroups.com.

Dick Davies

unread,
Sep 6, 2014, 3:57:12 AM9/6/14
to marathon-...@googlegroups.com
Ah I spoke to soon, you can use confd as an entrypoint so long as you
pass it the '-backend env' flag. That'll do what you want.
Reply all
Reply to author
Forward
0 new messages