Hi Oliver,

Yes you need to include the port range you want to use in your Task,
and later in the DockerInfo specifiy how do you want to use them (you
can map multiple ones in that list).

Thanks!

Tim

On Fri, May 29, 2015 at 5:43 AM, Olivier Sallou <[email protected]> wrote:
>
>
> On 05/29/2015 02:07 PM, Olivier Sallou wrote:
>> Hi,
>> I can run task with success in a Docker container in my mesos install
>> using base executor.
>>
>> However, I cannot get a task running when I add port mapping (though
>> port is available).
> ok, it appears that in addition to Docker port_mapping, we need to add a
> port resource declaration in the task too, with something like:
>
>                 ports = task.resources.add()
>                 ports.name = "ports"
>                 ports.type = mesos_pb2.Value.RANGES
>                 port_range = ports.ranges.range.add()
>                 port_range.begin=31000
>                 port_range.end=31000
>
> we kinda need to duplicate port declaration (task and docker) in task.
>
>
>> I use mesos 0.22, with python 2.7.
>>
>>
>> If I print the sent task I have:
>>
>> name: "task 0"
>> task_id {
>>   value: "0"
>> }
>> slave_id {
>>   value: "20150526-114150-16777343-5050-2035-S0"
>> }
>> resources {
>>   name: "cpus"
>>   type: SCALAR
>>   scalar {
>>     value: 1
>>   }
>> }
>> resources {
>>   name: "mem"
>>   type: SCALAR
>>   scalar {
>>     value: 128
>>   }
>> }
>> command {
>>   value: "echo \"hello world # $MESOS_SANDBOX #\""
>> }
>> container {
>>   type: DOCKER
>>   docker {
>>     image: "centos"
>>     network: BRIDGE
>>     port_mappings {
>>       host_port: 31000
>>       container_port: 22
>>     }
>>     force_pull_image: true
>>   }
>> }
>>
>> And it ends with error:
>>
>> Task 0 is in state TASK_FAILED
>> Abnormal executor termination
>>
>>
>> Slave shows:
>>
>> I0529 13:50:49.813928 18426 docker.cpp:626] Starting container
>> 'd9b5be3e-9f00-4242-aa91-d6a6f3a5175a' for task '0' (and executor '0')
>> of framework '20150529-103634-16777343-5050-18179-0020'
>> E0529 13:50:54.362663 18420 slave.cpp:3112] Container
>> 'd9b5be3e-9f00-4242-aa91-d6a6f3a5175a' for executor '0' of framework
>> '20150529-103634-16777343-5050-18179-0020' failed to start: Port
>> mappings require port resources
>>
>> However the offer present port resources:
>>
>> resources {
>>   name: "ports"
>>   type: RANGES
>>   ranges {
>>     range {
>>       begin: 31000
>>       end: 32000
>>     }
>>   }
>>   role: "*"
>> }
>>
>> At slave startup I also see:
>> I0529 14:05:37.481212 22455 slave.cpp:322] Slave resources: cpus(*):8;
>> mem(*):6900; disk(*):215925; ports(*):[31000-32000]
>>
>>
>> Any idea of what is going wrong?
>>
>>
>> Thanks
>>
>> Olivier
>>
>
> --
> Olivier Sallou
> IRISA / University of Rennes 1
> Campus de Beaulieu, 35000 RENNES - FRANCE
> Tel: 02.99.84.71.95
>
> gpg key id: 4096R/326D8438  (keyring.debian.org)
> Key fingerprint = 5FB4 6F83 D3B9 5204 6335  D26D 78DC 68DB 326D 8438
>

Reply via email to