title: How to deal with persistent storage (e.g. databases) in Docker
body: <p>How do people deal with persistent storage for your Docker containers?</p>
  
  <p>I am currently using this approach: build the image, e.g. for PostgreSQL, and then start the container with</p>
  
  <pre><code>docker run --volumes-from c0dbc34fd631 -d app_name/postgres
  </code></pre>
  
  <p>IMHO, that has the drawback, that I must not ever (by accident) delete container "c0dbc34fd631".</p>
  
  <p>Another idea would be to mount host volumes "-v" into the container, however, the <strong>userid</strong> within the container does not necessarily match the <strong>userid</strong> from the host, and then permissions might be messed up.</p>
  
  <p>Note: Instead of <code>--volumes-from 'cryptic_id'</code> you can also use <code>--volumes-from my-data-container</code> where <code>my-data-container</code> is a name you assigned to a data-only container, e.g. <code>docker run --name my-data-container ...</code> (see the accepted answer)</p>