Setting up a docker / fig Mesos environment

JRun picture JRun · Aug 9, 2014 · Viewed 18k times · Source

I'm trying to set up a docker / fig Mesos cluster. I'm new to fig and Docker. Docker has plenty of documentation, but I find myself struggling to understand how to work with fig.

Here's my fig.yaml at the moment:

zookeeper:
  image: jplock/zookeeper
  ports: 
  - "49181:2181"
mesosMaster:
  image: mesosphere/mesos:0.19.1
  ports: 
    - "15050:5050"
  links: 
    - zookeeper:zk
  command: mesos-master --zk=zk --work_dir=/var/log --quorum=1
mesosSlave:
  image: mesosphere/mesos:0.19.1
  links: 
    - zookeeper:zk
  command: mesos-slave --master=zk

Thanks !


Edit:

Thanks to Mark O`Connor's help, I've created a working docker-based mesos setup (+ storm, chronos, and more to come).

Enjoy, and if you find this useful - please contribute: https://github.com/yaronr/docker-mesos

PS. Please +1 Mark's answer :)

Answer

Mark O'Connor picture Mark O'Connor · Aug 9, 2014

You have not indicated the errors you were experiencing.

This is the documentation for the image you're using:

Mesos base Docker using the Mesosphere packages from https://mesosphere.io/downloads/. Doesn't start Mesos, please use the mesos-master and mesos-slave Dockers.

What really worried me about those images is that they were untrusted and no source was immediately available.

So I re-created your example using the mesosphere github as inspiration:

Updated Example

Example updated to include the chronos framework

├── build.sh
├── fig.yml
├── mesos
│   └── Dockerfile
├── mesos-chronos
│   └── Dockerfile
├── mesos-master
│   └── Dockerfile
└── mesos-slave
    └── Dockerfile

Build the base image (only has to be done once)

./build.sh

Run fig to start an instance of each service:

$ fig up -d
Creating mesos_zk_1...
Creating mesos_master_1...
Creating mesos_slave_1...
Creating mesos_chronos_1...

One useful thing about fig is that you can scale up the slaves

$ fig scale slave=5
Starting mesos_slave_2...
Starting mesos_slave_3...
Starting mesos_slave_4...
Starting mesos_slave_5...

The mesos master console should show 5 slaves running

http://localhost:15050/#/slaves

And the chronos framework should be running and ready to launch tasks

http://localhost:14400

fig.yml

zk:
  image: mesos
  command: /usr/share/zookeeper/bin/zkServer.sh start-foreground
master:
  build: mesos-master
  ports:
    - "15050:5050"
  links:
    - "zk:zookeeper"
slave:
  build: mesos-slave
  links:
    - "zk:zookeeper"
chronos:
  build: mesos-chronos
  ports:
    - "14400:4400"
  links:
    - "zk:zookeeper"

Notes:

  • Only single instance of zookeeper needed for this example

build.sh

docker build --rm=true --tag=mesos mesos

mesos/Dockerfile

FROM ubuntu:14.04
MAINTAINER Mark O'Connor <[email protected]>

RUN echo "deb http://repos.mesosphere.io/ubuntu/ trusty main" > /etc/apt/sources.list.d/mesosphere.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
RUN apt-get -y update
RUN apt-get -y install mesos marathon chronos

mesos-master/Dockerfile

FROM mesos
MAINTAINER Mark O'Connor <[email protected]>

EXPOSE 5050

CMD ["--zk=zk://zookeeper:2181/mesos", "--work_dir=/var/lib/mesos", "--quorum=1"]

ENTRYPOINT ["mesos-master"]

mesos-slave/Dockerfile

FROM mesos
MAINTAINER Mark O'Connor <[email protected]>

CMD ["--master=zk://zookeeper:2181/mesos"]

ENTRYPOINT ["mesos-slave"]

mesos-chronos/Dockerfile

FROM mesos
MAINTAINER Mark O'Connor <[email protected]>

RUN echo "zk://zookeeper:2181/mesos" > /etc/mesos/zk

EXPOSE 4400

CMD ["chronos"]

Notes:

  • The "chronos" command line is configured using files.