In this post, I will show you Mesos Docker container configuration. This allows you to schedule your own Docker containers on Mesos.
Mesos comes with it’s own container technology which is pretty cool in and of itself but it also has the option to make use of Docker to manage containers. This opens up a lot of possibilites for your mesos cluster.
If you have been following my posts about mesos then you should have a basic mesos cluster configured. This post builds on that post by enabling docker containers.
Since my first article setup mesos on Ubuntu 16.10 this article assumes the same. You can still follow this post if you have a different linux distribution, just find the instructions for installing Docker on your distribution.
Mesos Slave Configuration
All of the configuration performed for this post will be done on the mesos slaves. You will not have to do anything on the master(s).
Our first task will be to install Docker on our mesos slave.
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-yakkety main' sudo apt update sudo apt install -y docker-engine
Since we installed Mesos to use a Systemd service file which runs as the root user, we don’t need to worry about giving other users access to running docker.
Update Mesos SystemD Service
Now we need to update our /etc/systemd/system/mesos-slave.service file to make use of Docker. Add these options to the ExecStartline:
--containerizers=docker,mesos --image_providers=appc,docker --isolation=filesystem/linux,docker/runtime
Your mesos-slave.service file should now look like this:
[Unit] Description=Mesos Slave Service [Service] ExecStart=/usr/local/sbin/mesos-slave --master=zk://192.168.1.30:2181,192.168.1.31:2181,192.168.1.32:2181/mesos --work_dir=/var/lib/mesos --containerizers=docker,mesos --image_providers=appc,docker --isolation=filesystem/linux,docker/runtime [Install] WantedBy=multi-user.target
Save the file and exit.
Next we need to configure IPTables to allow traffic through the docker0 interface:
iptables -A INPUT -s 172.17.0.0/16 -i docker0 -p tcp -j ACCEPT
The last step is to restart the slave service.
sudo systemctl daemon-reload sudo systemctl restart mesos-slave.service
You now have docker enabled as a containerizer for mesos.
Conclusion / Next Steps
To make use of Docker containers you will need to use Marathon, which if you followed my post CONFIGURING A MESOS/MARATHON CLUSTER ON UBUNTU 16.04 you already have! If not then you can follow the Marathon Installation section in that post to get it running. Look for a post soon on how to run a docker container in Marathon.
I hope you enjoyed this post. If it was helpful or if it was way off then please comment and let me know.
I hope you have enjoyed this article, if so please leave a comment below. For more articles, please signup for the AdminTome Blog below. Also please feel free to share the article to your friends using the buttons to the left. Thanks again for reading this post.