Package: deimos
Deimos is a Docker plugin for Mesos, providing external containerization as
described inMESOS-816.InstallationFor a complete installation walkthrough, seethis Gist.Deimos can be installedfrom the Cheeseshop.pipinstalldeimosPassing Parameters to DockerIn Mesos, every successful resource offer is ultimately followed up with aTaskInfothat describes the work to be done. Within theTaskInfois aCommandInfoand within theCommandInfothere is aContainerInfo(followingMESOS-816). TheContainerInfostructure allows specification
of animage URLandcontainer options. For example:{container=ContainerInfo{image="docker:///ubuntu"options=["-c","10240"]}}Deimos handles image URLs beginning withdocker:///by stripping the
prefix and using the remainder as the image name. The container options are
passed todocker runwhen the task is launched. If a//is found in the
options list, all the following arguments will be append to the the end of
the run command. This is useful when using an image with an entrypoint defined.
For example:{container=ContainerInfo{image="docker:///flynn/slugrunner"options=["//","start","web"]}}If noContainerInfois present in a task, Deimos will still containerize
it, by using the--default_container_imagepassed to the slave, or taking
a reasonable guess based on the host’s distribution and release.Some options for Docker, like-H, do not apply only todocker run.
These options should be set in the Deimos configuration file.Deimos recognizes Mesos resources that specify ports, CPUs and memory and
translates them to appropriate Docker options.Passing Parameters through MarathonMarathon has a REST api to submit JSON-formatted requests to run long-running commands.From this JSON object, the following keys are used by Deimos:containerA nested object with details about what Docker image to runimageWhat Docker image to run, it may have a custom registry but
must have a version tagoptionsA list of extra options to add to the Docker invocationcmdWhat command to run with Docker inside the image. Deimos
automatically adds/bin/sh-cto the frontenvExtra environment variables to pass to the Docker imagecpusHow many CPU shares to give to the container, can be fractional,
gets multiplied by 1024 and added withdocker run-cmemHow much memory to give to the container, in megabytescurl-v-XPOSThttp://mesos1.it.corp:8080/v2/apps\-HContent-Type:application/json-d'{
    "id": "marketing",
    "container": {
      "image": "docker:///registry.int/marketing:latest",
      "options": ["-v", "/srv:/srv"]
    },
    "cmd": "/webapp/script/start.sh",
    "env": {"VAR":"VALUE"},
    "cpus": 2,
    "mem": 768.0,
    "instances": 2
}'This turns into a Docker execution line similar to this:dockerrun--sig-proxy--rm\--cidfile/tmp/deimos/mesos/10330424-95c2-4119-b2a5-df8e1d1eead9/cid\-w/tmp/mesos-sandbox\-v/tmp/deimos/mesos/10330424-95c2-4119-b2a5-df8e1d1eead9/fs:/tmp/mesos-sandbox\-v/srv:/srv-p31014:3000\-c2048-m768m\-ePORT=31014-ePORT0=31014-ePORTS=31014-eVAR=VALUE\registry.int/marketing:latestsh-c"/webapp/script/start.sh"LoggingDeimos logs to the console when run interactively and to syslog when run in the
background. You can configure logging explicitly in the Deimos configuration
file.ConfigurationThere is an example configuration file inexample.cfgwhich documents all
the configuration options. The two config sections that are likely to be most
important in production are:[docker]: global Docker options (--host)[log]: logging settingsConfiguration files are searched in this order:./deimos.cfg~/.deimos/etc/deimos.cfg/usr/etc/deimos.cfg/usr/local/etc/deimos.cfgOnly one configuration file – the first one found – is loaded. To see what
Deimos thinks its configuration is, rundeimos config.The State DirectoryDeimos creates a state directory for each container, by default under/tmp/deimos, where it tracks the container’s status, start time and PID.
File locks are maintained for each container to coordinate invocations of
Deimos that start, stop and probe the container.To clean up state directories belonging to exited containers, invoke Deimos
as follows:deimosstate--rmThis task can be run safely from Cron at a regular interval. In the future,
Deimos will not require separate invocation of thestatesubcommand for
regular operation.Configuring Mesos To Use DeimosOnly the slave needs to be configured. Set these options:--containerizer_path=/usr/local/bin/deimos--isolation=externalThe packaged version of Mesos can also load these options from files:echo/usr/local/bin/deimos>/etc/mesos-slave/containerizer_pathechoexternal>/etc/mesos-slave/isolation