Docker announced compose on February 26th. Compose allows you to describe a multi-container setup and manage it with one binary
docker-compose. The containers and volumes combinations managed by Compose are defined in a YAML file, super easy to read and super easy to write. The UX is very similar to the Docker CLI.
When compose was released, I tried it and was a bit underwhelmed, as it is basically a relooking of Fig. This is not unexpected as Docker Inc, acquired Orchard the makers of Fig. But I was expecting more added functionality and even a tighter integration with the Docker client (something a dev branch actually prototyped), even a common release instead of a separate binary. I am sure this will come.
As I am writing the docker cookbook, I have deployed Wordpress 20 different ways, and it's getting a bit boring ! I was looking for more information on Mesos and its support for Docker, I re-read a terrific blog post that showed how to start a Mesos setup (zookeeper, master, slave, marathon framework) in 7 commands. Can't beat that.
When I re-read this post, I automatically thought this was an exciting use case for
docker-compose. One YAML file to start Mesos/Zookeeper/Marathon and experiment with it. Of course I am not talking about a production multi-node setup. I am just looking at it for an easy Mesos experiment.
I will spare you the details of installing compose (just a curl away). The dockers docs are great.
So here is the YAML file describing our Mesos setup:
zookeeper: image: garland/zookeeper ports: - "2181:2181" - "2888:2888" - "3888:3888" mesosmaster: image: garland/mesosphere-docker-mesos-master ports: - "5050:5050" links: - zookeeper:zk environment: - MESOS_ZK=zk://zk:2181/mesos - MESOS_LOG_DIR=/var/log/mesos - MESOS_QUORUM=1 - MESOS_REGISTRY=in_memory - MESOS_WORK_DIR=/var/lib/mesos marathon: image: garland/mesosphere-docker-marathon links: - zookeeper:zk - mesosmaster:master command: --master zk://zk:2181/mesos --zk zk://zk:2181/marathon ports: - "8080:8080" mesosslave: image: garland/mesosphere-docker-mesos-master:latest ports: - "5051:5051" links: - zookeeper:zk - mesosmaster:master entrypoint: mesos-slave environment: - MESOS_HOSTNAME=192.168.33.10 - MESOS_MASTER=zk://zk:2181/mesos - MESOS_LOG_DIR=/var/log/mesos - MESOS_LOGGING_LEVEL=INFO
Four containers, images pulled from Docker hub, some ports exposed on the host. Some container linking and some environment variables used to configure the Mesos slave and master. One small hickup in the Slave defintion. You will see that I set the MESOS_HOSTNAME to the IP of the host. This allows me to browse the stdout and stderr of a Marathon task, otherwise we cannot reach it easily (small improvement to be done there.)
Launch this with
$ ./docker-compose up -d Recreating vagrant_zookeeper_1... Recreating vagrant_mesosmaster_1... Recreating vagrant_marathon_1... Recreating vagrant_mesosslave_1...
And open your browser at http://IP_HOST
Don't know of any use cases for which doing the following would be useful, but I did get your YML deployed to http://tutum.co without a hiccup.ReplyDelete
$ tutum stack up -f goasguen-mesos.yml
Pretty cool stuff!
I havent try your yaml file yet.ReplyDelete
But the mesos-slave container is started without the exposing /sys of the host. Will it work without cgroup?
I think the original plan was to include docker-compose in the docker binary, but there was a lot of complaints about this from the community that caused a change of heart.ReplyDelete
Hey, thanks for the writeup! I ended up implementing something similar based on it, and had a couple of questions.ReplyDelete
1) Do you need to publish all those ports to the host? As far as I know, the only ones you should need to access from outside those containers are 5050 and 8080, but I'm not an expert on Mesos.
2) Is there a reason you're linking to the Mesos master from the slave and Marathon, or is that just to make sure the master starts before the other two? Removing it only seemed to cause intermittent error messages right during startup that were resolved fairly quickly. Just wanted to make sure there wasn't another reason for it.
3) You can probably use the official mesosphere images here for better maintainability. I have an example up here.