I wanted to see if I could get a Docker + Mesos + Marathon platform up and running quickly in AWS EC2 using t2.micro instances. I found this great article by Gar (@gargar454) where he has put all the components in docker containers and provides a simple tutorial which I paste below with some minor edits:
- https://github.com/sekka1/mesosphere-docker
- https://medium.com/@gargar454/deploy-a-mesos-cluster-with-7-commands-using-docker-57951e020586#.fz8mapida
Create a Docker Host on EC2
Create your EC2 instances (Amazon AMI t2.micro will work), set it up in your private VPC and auto-assign a public IP so you can test. You will need to open TCP ports 5050 and 8080 in your security group from your workstation if you want to see the Mesos and Marathon UIs. Run these commands to set up a docker host:
sudo yum update -y sudo yum install -y docker sudo service docker start # grant ec2-user ability to run docker commands without sudo sudo usermod -a -G docker ec2-user # you must exist to refresh user rights exit
- Export out the local host’s IP
-
HOST_IP=`wget -qO- http://instance-data/latest/meta-data/local-ipv4`
-
- Start Zookeeper
docker run -d \ -p 2181:2181 \ -p 2888:2888 \ -p 3888:3888 \ garland/zookeeper
- 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
- Start Marathon
docker run \ -d \ -p 8080:8080 \ garland/mesosphere-docker-marathon --master zk://${HOST_IP}:2181/mesos --zk zk://${HOST_IP}:2181/marathon
- 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
- Goto the Mesos & Marathon Web pages
# You can find your EC2 instance public IP address with:
wget -qO- http://instance-data/latest/meta-data/public-ipv4Mesos Web Page
-
http://<public-ip>:5050
Marathon Web Page
http://<public-ip>:8080
Create an App (+ New App button) on the Marathon page to see the task get assigned to a Mesos slave and executed.
Log in to the slave container and watch the file grow:
docker exec -it mesos_slave_1 /bin/bash tail -f /tmp/running.out