title: How to mount HDFS in a Docker container
body: <p>I made an application Dockerized in a Docker container. I intended to make the application able to access files from our HDFS. The Docker image is to be deployed on the same cluster where we have HDFS installed via Marathon-Mesos. </p>
  
  <p>Below is the json to be POST to Marathon. It seems that my app is able to read and write files in the HDFS. Can someone comment on the safety of this? Would files changed by my app correctly changed in the HDFS as well? I Googled around and didn't find any similar approaches...</p>
  
  <pre><code>{
    "id": "/ipython-test",
    "cmd": null,
    "cpus": 1,
    "mem": 1024,
    "disk": 0,
    "instances": 1,
    "container": {
      "type": "DOCKER",
      "volumes": [
        {
          "containerPath": "/home",
          "hostPath": "/hadoop/hdfs-mount",
          "mode": "RW"
        }
      ],
      "docker": {
        "image": "my/image",
        "network": "BRIDGE",
        "portMappings": [
          {
            "containerPort": 8888,
            "hostPort": 0,
            "servicePort": 10061,
            "protocol": "tcp",
          }
        ],
        "privileged": false,
        "parameters": [],
        "forcePullImage": true
      }
    },
    "portDefinitions": [
      {
        "port": 10061,
        "protocol": "tcp",
        "labels": {}
      }
    ]
  }
  </code></pre>