With mesos .20 and marathon .71 and using docker containers, the method that 
works for me is to specify no ports in the json task spec:

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "johncosta/redis"
    },
    "volumes" : []
  },
  "id": "redis-server",
  "instances": "1",
  "cpus": "0.5",
  "mem": "256",
  "ports": [0],
  "uris": [],
  "cmd": ""
}

A port will be assigned to this task.  You can use docker inspect to see that 
on the slave.  It will be passed in as the environment variable PORT0.  Your 
executable needs to leverage this as the port.  Clients will need to 
interrogate marathon or use a custom intermediary to connect with the service 
port.

You can specify additional ports (“ports": [0, 0, 0] and use PORT0, PORT1 and 
PORT2 as an example)

The above mesos/marathon combo will not work for off the shelf docker images.

On Sep 30, 2014, at 4:06 PM, Yonatan Ryabinski <cig...@gmail.com> wrote:

> Hey,
> 
> How can one expose docker ports via marathon? There is the ports key of the 
> .json file but that doesn't seem to expose the docker ports. 
> 
> Please advise.
> 
> 
> --
> Thanks,
> Yoni.
> 
> PGP Public Key
> 
> On Tue, Sep 30, 2014 at 4:32 PM, Steve Domin <st...@gocardless.com> wrote:
> Hi Luyi,
> 
> By "how internally these instances are connected" do you refer to some kind 
> of service discovery? If so, there's nothing really built into Marathon for 
> that, you'll have to use another service.
> 
> There's a script provided by Marathon that updates an HAProxy config but it 
> means you'd have to put your database behind HAProxy, which may or may not 
> work in your case.
> 
> Steve
> 
> On Tue, Sep 30, 2014 at 7:47 PM, Luyi Wang <wangluyi1...@gmail.com> wrote:
> Hey all :
> 
> 
> My question is  what's the best way to running mysql or postgresq on mesos 
> with marathon. 
> 
> I saw my posts just mentioned the way doing the scale using marathon, but 
> didn't explain how internally these instances are connected ?
> 
> Can anyone point out the places I can refer to or give me some insights on 
> this. 
> 
> Thanks. 
> 
> 
> 
> 
> -Luyi.
> 
> 
> 
> 
> 

Reply via email to