title: Manually sharing directory as docker volume mounting point on OSX
body: <p>According to this <a href="https://docs.docker.com/engine/installation/mac/#mount-a-volume-on-the-container" rel="nofollow">tutorial from docker website</a>, <em>When you start a container it automatically shares your <code>/Users/username</code></em>.</p>
  
  <h2>My current problem :</h2>
  
  <p>But in my school my <code>$HOME</code> isn't in <code>/Users</code>, and when I try to directly mount volumes on my container with something like <code>docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx</code> (like the tutorial from the link), I can't change files through the mounted volume. So I guess my <code>$HOME</code> isn't automatically shared.</p>
  
  <p>But if I run <code>docker instpect mysite</code> I get :</p>
  
  <pre><code>"HostConfig": {
      "Binds": [
          "/nfs/zfs-student-3/users/vmonteco/site:/usr/share/nginx/html"
      ],
  </code></pre>
  
  <p>and</p>
  
  <pre><code>"Mounts": [
      {
          "Source": "/nfs/zfs-student-3/users/vmonteco/site",
          "Destination": "/usr/share/nginx/html",
          "Mode": "",
          "RW": true,
          "Propagation": "rprivate"
      } 
  </code></pre>
  
  <h2>My question is simply this :</h2>
  
  <p><strong>How could I manually share directories with the VM hosting docker (virtualbox here) to use it as volume mounting points?</strong></p>
  
  <h2>This is how I did it with Boot2docker before it was deprecated :</h2>
  
  <p>With <strong>boot2docker</strong> I could have run something like :</p>
  
  <pre><code>SHAREDIR=$HOME/share
  # creating share folder.
  mkdir $SHAREDIR
  
  # mount shared folder while relaunching boot2docker :
  boot2docker --vbox-share="$SHAREDIR=share" up
  echo "Creating and mounting \"share\" directory in boot2docker VM."
  boot2docker ssh "sudo mkdir /share; sudo mount -t vboxsf share /share"
  
  # running the container :
  docker run  -ti --rm -v /share:/share -v /Users:/Users base/archlinux sh
  </code></pre>
  
  <p>And it worked fine.</p>
  
  <p>But now <strong>boot2docker</strong> is <strong>deprecated</strong> and I didn't find how to do this with the VM I have to use now (it uses virtualbox).</p>
  
  <p>If I understand well, it should work the same way as boot2docker worked :</p>
  
  <pre><code>                       1                                                  2
  [directory from OSX] &lt;===&gt; [VM directory (the VM replaces Boot2docker)] &lt;===&gt; [container directory]
  </code></pre>
  
  <p>If I still understand well the only that doesn't work now is the point <strong>[1]</strong>, this was handled by the middle part of the little script I just shared with boot2docker.</p>
  
  <p>But how could I do now?</p>