Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Thursday, 28 January 2016

Launching Containers Using Docker on Mesos and Marathon

Mesos and Marathon Setup



Installing Docker


use the below command to install docker 

curl -sSL https://get.docker.com/ | sh

Configuring mesos to allow Docker

echo 'docker,mesos' | sudo tee /etc/mesos-slave/containerizers
echo '5mins' > /etc/mesos-slave/executor_registration_timeout

Launching Docker Containers using Marathon Framework
sample marathon application definition (JSON) to run redis

redis.json
{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "redis"
    }
  },
  "id": "redis",
  "instances": 1,
  "cpus": 0.25,
  "mem": 256,
  "uris": []
}




Use the below REST API call to deploy redis container

curl -i -H 'Content-Type: application/json' -d@redis.json marathon_host:8080/v2/apps


Now you can check the deployed app / container in different ways

  • Using marathon Web UI
  • Using mesos Web UI
  • Marathon REST API
         curl http://0.0.0.0:8080/v2/apps | python -m json.tool

  •  Using Docker commands
          $sudo docker ps


          CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS         NAMES
           bc113e5ae582        redis               "/entrypoint.sh redis"      1 hours ago        Up 1 hours                             mesos-20150811-053134-2734729408-5050-28597-S0.3db57667-b60c-4dc1-9318-df5e8b3d4302