Register Now

One Command to Mesos with Docker Compose


Reading Time: 3 minutes

This article was originally published on Sebastien Goasguen’s blog and we are sharing it here for Codeship readers. Sebastien is an EMEA Open Source Cloud Computing Evangelist for Citrix. You can find out more about him on his blog.

If you have not tried Docker, you should. The sheer power it puts in your hands and the simplicity of the user experience will just wow you. In this post, I will show you how to start a one node Mesos setup with Docker Compose.

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 and I 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.

Sign up for a free Codeship Account

When I 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 docker docs are great help.

So here is the YAML file describing our Mesos setup:

     image: garland/zookeeper 
     - "2181:2181" 
     - "2888:2888" 
     - "3888:3888" 
     image: garland/mesosphere-docker-mesos-master 
     - "5050:5050" 
     - zookeeper:zk 
     - 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 
     image: garland/mesosphere-docker-marathon 
     - zookeeper:zk 
     - mesosmaster:master 
    command: --master zk://zk:2181/mesos --zk zk://zk:2181/marathon 
     - "8080:8080" 
     image: garland/mesosphere-docker-mesos-master:latest 
     - "5051:5051" 
      - zookeeper:zk 
     - mesosmaster:master 
     entrypoint: mesos-slave 
     - MESOS_MASTER=zk://zk:2181/mesos 
     - MESOS_LOG_DIR=/var/log/mesos 

Four containers, images pulled from Docker hub, and some ports exposed on the host. Some container linking and some environment variables used to configure the Mesos slave and master. One small hiccup 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:

$ ./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:5050 then follow the rest of the blog to start a task in marathon. one command to mesos with docker compose

Bottom line, I went from ‘seven commands to Mesos’ to ‘one command to Mesos’ thanks to Docker-compose and a fairly simple YAML file. Got to love it. When Compose can do this across Docker hosts in a Docker Swarm started by Machine…then the real fun will begin!

Are you interested in more articles like this one? Please let us know in the comments! Should you be interested in additional Mesos related posts you might want to read this article on our blog: A Virtual Mesos Cluster with Vagrant and Chef

Subscribe via Email

Over 60,000 people from companies like Netflix, Apple, Spotify and O'Reilly are reading our articles.
Subscribe to receive a weekly newsletter with articles around Continuous Integration, Docker, and software development best practices.

We promise that we won't spam you. You can unsubscribe any time.

Join the Discussion

Leave us some comments on what you think about this topic or if you like to add something.