docker-shm.json

DC/OS Shared Memory Example Between UCR Containers in a Pod and a Docker Container

0

Votes

{
  "env": {},
  "id": "/centos-docker",
  "backoffFactor": 1.15,
  "backoffSeconds": 1,
  "cmd": "sh -c df -hf && for i in {1..100000}; do echo -n \"Iteration $i \"; ls -la /dev/shm ; echo writing $i > /dev/shm/ucr ; cat /dev/shm/ucr ; sleep 5; done",
  "constraints": [
    [
      "hostname",
      "LIKE",
      "172.16.22.86"
    ]
  ],
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "centos:latest",
      "forcePullImage": false,
      "privileged": false,
      "parameters": [
        {
          "key": "shm-size",
          "value": "16384mb"
        },
        {
          "key": "ipc",
          "value": "host"
        }
      ]
    }
  },
  "cpus": 1,
  "disk": 0,
  "instances": 1,
  "maxLaunchDelaySeconds": 3600,
  "mem": 1024,
  "gpus": 0,
  "networks": [
    {
      "mode": "host"
    }
  ],
  "portDefinitions": [],
  "requirePorts": false,
  "upgradeStrategy": {
    "maximumOverCapacity": 1,
    "minimumHealthCapacity": 1
  },
  "killSelection": "YOUNGEST_FIRST",
  "unreachableStrategy": {
    "inactiveAfterSeconds": 0,
    "expungeAfterSeconds": 0
  },
  "healthChecks": [],
  "fetch": []
}
 ucr-shm.json
{
  "id": "/shm",
  "version": "2019-04-04T18:04:30.967Z",
  "containers": [
    {
      "name": "container-1",
      "resources": {
        "cpus": 0.1,
        "mem": 10240,
        "disk": 0,
        "gpus": 0
      },
      "exec": {
        "command": {
          "shell": "sh -c df -hf && for i in {1..100000}; do echo -n \"Iteration UCR 1 $i > /dev/shm/ucr\"; dd if=/dev/zero of=/dev/shm/ucr-1-$i.txt count=1024 bs=1024 ; ls -la /dev/shm ; cat /dev/shm/ucr ; sleep 5; done"
        }
      },
      "image": {
        "kind": "DOCKER",
        "id": "centos:latest"
      },
      "volumeMounts": [
        {
          "name": "sharedmem",
          "mountPath": "/dev/shm"
        }
      ]
    },
    {
      "name": "container-2",
      "resources": {
        "cpus": 0.1,
        "mem": 10240,
        "disk": 0,
        "gpus": 0
      },
      "exec": {
        "command": {
          "shell": "sh -c df -hf && for i in {1..100000}; do echo -n \"Iteration UCR 2 $i > /dev/shm/ucr\"; dd if=/dev/zero of=/dev/shm/ucr-2-$i.txt count=1024 bs=1024 ; ls -la /dev/shm ; cat /dev/shm/ucr ; sleep 5; done"
        }
      },
      "image": {
        "kind": "DOCKER",
        "id": "centos:latest"
      },
      "volumeMounts": [
        {
          "name": "sharedmem",
          "mountPath": "/dev/shm"
        }
      ]
    }
  ],
  "volumes": [
    {
      "name": "sharedmem",
      "host": "/dev/shm"
    }
  ],
  "networks": [
    {
      "mode": "host"
    }
  ],
  "scaling": {
    "instances": 1,
    "kind": "fixed"
  },
  "scheduling": {
    "backoff": {
      "backoff": 1,
      "backoffFactor": 1.15,
      "maxLaunchDelay": 3600
    },
    "upgrade": {
      "minimumHealthCapacity": 1,
      "maximumOverCapacity": 1
    },
    "placement": {
      "constraints": [
        {
          "fieldName": "hostname",
          "operator": "LIKE",
          "value": "172.16.22.86"
        }
      ]
    },
    "killSelection": "YOUNGEST_FIRST",
    "unreachableStrategy": {
      "inactiveAfterSeconds": 0,
      "expungeAfterSeconds": 0
    }
  },
  "executorResources": {
    "cpus": 0.1,
    "mem": 32,
    "disk": 10
  },
  "fetch": []
}

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png