mesos / mesos-go

Go language bindings for Apache Mesos
Apache License 2.0
545 stars 146 forks source link

Question: How do I mount a host folder? #302

Closed Spritekin closed 7 years ago

Spritekin commented 7 years ago

Hi, I need to mount a folder in the host into a container. May anybody tell me how to do this with mesos-go? Is there an example? Is it possible at all?

Thanks!

jdef commented 7 years ago

there isn't a golang example yet. volumes are part of ContainerInfo, you'll need Mode, HostPath, and ContainerPath. xref https://github.com/mesosphere/marathon/blob/c81becd819a15a667a4f44f867fbfffa9ff484c6/src/main/scala/mesosphere/mesos/TaskGroupBuilder.scala#L316

Spritekin commented 7 years ago

Good enough for me... will try and report.

Spritekin commented 7 years ago

I did this in my go code:

import (
   "github.com/mesos/mesos-go/mesosproto"
)

type Task struct {
    mesosproto.TaskInfo
    ... other stuff here...   
}

Then using t Task

    t.Container.Volumes = append(t.Container.Volumes, &mesosproto.Volume{
                    Mode:          mesosproto.Volume_RW.Enum(),
                    HostPath:      proto.String("/my/host/path"),
                    ContainerPath: proto.String("/my/container/path"),
                })
    ... other mesos/docker initialisation stuff ...

Sent to mesos it mounted ok!

Quite a nice library you got here. Kudos.