This tutorial will show you how to bring up a single node Mesos cluster all provisioned out using Docker containers (a future post will show how to easily scale this out to multi nodes or see the update on the bottom). This means that you can startup an entire cluster with 7 commands! Nothing to install except for starting out with a working Docker server.

This will startup 4 containers:

ZooKeeper Meso Master Marathon Mesos Slave Container

As mentioned the only prerequisite is to have a working Docker server. This means you can bring up a local Vagrant box with Docker installed, use Boot2Docker, use CoreOS, instance on AWS, or however you like to get a Docker server.

The entire process is outlined in this Github repository.

All of the Docker container build files used are there also. You can build each container locally or just use the pre-built containers located on the Docker Hub. The commands below will automatically download the needed pre-built containers for you.

ZooKeeper — https://registry.hub.docker.com/u/garland/zookeeper/

Meso Master — https://registry.hub.docker.com/u/garland/mesosphere-docker-mesos-master/

Marathon — https://registry.hub.docker.com/u/garland/mesosphere-docker-marathon/

Let’s Get Started

Step 1: Get the IP of the Docker server and export it out to the environment. We will use this IP over and over again in subsequent Docker commands.

Just as a note, this is the IP address of the server and not docker0 or an IP address inside a Docker container. If you ssh into your server and run the command “ifconfig” use the eth0 interface’s address.

root@docker-server:/# HOST_IP=10.11.31.7

Step 2: Start the ZooKeeper container.

docker run -d \

-p 2181:2181 \

-p 2888:2888 \

-p 3888:3888 \

garland/zookeeper

Step 3: Start Mesos Master

docker run --net="host" \

-p 5050:5050 \

-e "MESOS_HOSTNAME=${HOST_IP}" \

-e "MESOS_IP=${HOST_IP}" \

-e "MESOS_ZK=zk://${HOST_IP}:2181/mesos" \

-e "MESOS_PORT=5050" \

-e "MESOS_LOG_DIR=/var/log/mesos" \

-e "MESOS_QUORUM=1" \

-e "MESOS_REGISTRY=in_memory" \

-e "MESOS_WORK_DIR=/var/lib/mesos" \

-d \

garland/mesosphere-docker-mesos-master

Step 4: Start Marathon

docker run \

-d \

-p 8080:8080 \

garland/mesosphere-docker-marathon --master zk://${HOST_IP}:2181/mesos --zk zk://${HOST_IP}:2181/marathon

Step 5: Start Mesos Slave in a container

docker run -d \

--name mesos_slave_1 \

--entrypoint="mesos-slave" \

-e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" \

-e "MESOS_LOG_DIR=/var/log/mesos" \

-e "MESOS_LOGGING_LEVEL=INFO" \

garland/mesosphere-docker-mesos-master:latest

Step 6: Goto the Mesos’ webpage

Depending on how you brought up your Docker server and it’s IP address you might have to change the IP you point your browser to but the port will be the same.

The Mesos webpage will be at this address:

http://${HOST_IP}:5050

Then you should get a page like this but probably at first without all the items in the “Tasks” tables.

Step 7: Goto Marathon’s webpage to start a job

The Marathon webpage lets you schedule long running tasks onto the Meso Slave container. This is a good test to see if your cluster is up and running. You can view the Marathon’s webpage at:

http://${HOST_IP}:8080

Clicking on the “New App” button on the top right gives you the following menu where you can create a new job/task. We are simply going to echo out hello to a file. We can go into the container and check if the file is created and if the job is continuously running.

Step 8: Check if job/task is running

Let’s check if the job/task is continuously running on the Mesos Slave.

On the Docker server run the following commands. It will place you inside the slave container and from there tail out the output.txt file.

docker exec -it mesos_slave_1 /bin/bash

root@ca83bf0ea76a:/# tail -f /tmp/output.txt

You will see “hello” being placed into this file about once a second.

Update: I just updated this projects doc to include how to setup a multi node environment: https://github.com/sekka1/mesosphere-docker#multi-node-setup

Here is the same article but translated to Chinese: http://dockerone.com/article/136

—

ManagedKube built k8sBot, a point-and-click interface for Kubernetes in Slack. Now, software developers and novice k8s users can get meaningful Kubernetes information with just one click in Slack, where you’re already talking with your team. With k8sBot, you can retrieve pod status, get pod logs, and get troubleshooting recommendations based on real-time information from your cluster’s Kubernetes API.

Learn more and start a free trial of k8sBot at managedkube.com