mesosphere-backup / deimos

Mesos containerizer hooks for Docker
Apache License 2.0
249 stars 26 forks source link

Possible to run any docker container? #27

Closed jplock closed 10 years ago

jplock commented 10 years ago

Is it possible to run any docker container available in the registry or only containers based upon libmesos/ubuntu?

For example, I have some containers that start their single internal process as soon as they are launched, so I'd like to do something like:

{
  "container": {
    "image": "docker:///jplock/rabbitmq",
    "options": []
  },
  "id": "rabbitmq",
  "instances": "1",
  "cpus": ".5",
  "mem": "300",
  "uris": [ ],
  "cmd": ""
}

with no cmd specified and no options provided. Should that work or what is the significance of libmesos/ubuntu? This container exists in the Docker registry at https://hub.docker.com/u/jplock/rabbitmq/ and I am able to run docker pull jplock/rabbitmq to download it. Thanks.

solidsnack commented 10 years ago

A daemon container like that should "just work". The integration tests cover a similar use case:

class PGScheduler(Scheduler):
    def __init__(self, sleep=10,
                       container="docker:///zaiste/postgresql",
                       trials=10):
        Scheduler.__init__(self, trials)
        self.container = container
        self.sleep = sleep
    def statusUpdate(self, driver, update):
        super(type(self), self).statusUpdate(driver, update)
        if update.state == mesos_pb2.TASK_RUNNING:
            def end_task():
                time.sleep(self.sleep)
                driver.killTask(update.task_id)
            thread = threading.Thread(target=end_task)
            thread.daemon = True
            thread.start()
        if self.all_tasks_done():
            self.sum_up()
            driver.stop()
    def resourceOffers(self, driver, offers):
        for offer in offers:
            if len(self.tasks) >= self.trials: break
            tid  = self.next_task_id()
            sid  = offer.slave_id
            task = task_with_daemon(tid, sid, self.container)
            self.tasks += [task]
            self.loggers[tid].info(present_task(task))
            driver.launchTasks(offer.id, [task])

https://github.com/mesosphere/deimos/blob/master/integration-test/deimos-test.py#L93

ssorallen commented 10 years ago

@jplock, did you have any problems running other Docker images? We use Deimos internally and run images not based off "libmesos/ubuntu". The container needs to have no knowledge it is being run on top of Mesos.

jplock commented 10 years ago

I think this was solved in a later deimos release so I think it can be closed.