title: How to mount a host directory in a Docker container
body: <p>I am trying to mount a host directory into a Docker container so that any updates done on the host is reflected into the Docker containers.</p>
  
  <p>Where am I doing something wrong. Here is what I did:</p>
  
  <pre><code>kishore$ cat Dockerfile
  
  FROM ubuntu:trusty
  RUN apt-get update
  RUN apt-get -y install git curl vim
  CMD ["/bin/bash"]
  WORKDIR /test_container
  VOLUME ["/test_container"]
  </code></pre>
  
  <p><pre><code>kishore$ tree
  .
  ├── Dockerfile
  └── main_folder
      ├── tfile1.txt
      ├── tfile2.txt
      ├── tfile3.txt
      └── tfile4.txt</p>
  
  <p>1 directory, 5 files
  kishore$ pwd
  /Users/kishore/tdock
  </code></pre><pre><code>kishore$ docker build --tag=k3_s3:latest .</p>
  
  <pre><code>Uploading context 7.168 kB
  Uploading context
  Step 0 : FROM ubuntu:trusty
   ---&gt; 99ec81b80c55
  Step 1 : RUN apt-get update
   ---&gt; Using cache
   ---&gt; 1c7282005040
  Step 2 : RUN apt-get -y install git curl vim
   ---&gt; Using cache
   ---&gt; aed48634e300
  Step 3 : CMD ["/bin/bash"]
   ---&gt; Running in d081b576878d
   ---&gt; 65db8df48595
  Step 4 : WORKDIR /test_container
   ---&gt; Running in 5b8d2ccd719d
   ---&gt; 250369b30e1f
  Step 5 : VOLUME ["/test_container"]
   ---&gt; Running in 72ca332d9809
   ---&gt; 163deb2b1bc5
  Successfully built 163deb2b1bc5
  Removing intermediate container b8bfcb071441
  Removing intermediate container d081b576878d
  Removing intermediate container 5b8d2ccd719d
  Removing intermediate container 72ca332d9809
  </code></pre>
  
  <p>kishore$ docker run -d -v /Users/kishore/main_folder:/test_container k3_s3:latest
  <code>c9f9a7e09c54ee1c2cc966f15c963b4af320b5203b8c46689033c1ab8872a0ea</code></code></pre><pre><code>kishore$ docker run -i -t k3_s3:latest /bin/bash</p>
  
  <pre><code>root@0f17e2313a46:/test_container# ls -al
  total 8
  drwx------  2 root root 4096 Apr 29 05:15 .
  drwxr-xr-x 66 root root 4096 Apr 29 05:15 ..
  </code></pre>
  
  <p>root@0f17e2313a46:/test_container# exit
  exit</code></pre><pre><code>kishore$ docker -v
  Docker version 0.9.1, build 867b2a9</code></pre></p>
  
  <ul>
  <li>I don't know how to check boot2docker version</li>
  </ul>
  
  <p>Questions, issues facing:</p>
  
  <ol>
  <li>How do I need to link the main_folder to the test_container folder present inside the docker container?</li>
  <li>I need to make this automatically. How do I to do that without really using the <code>run -d -v</code> command?</li>
  <li>What happens if the boot2docker crashes? Where are the Docker files stored (apart from Dockerfile)?</li>
  </ol>