title: How can I mount an absolute host path as a named volume in docker-compose?
body: <p>I've already tried the solution in <a href="https://stackoverflow.com/questions/35841241/docker-compose-named-mounted-volume">this stackoverflow thread</a>. It did not work for me, as shown below.</p>
  
  <p>Here's my <code>docker-compose.yml</code> file:</p>
  
  <pre><code>version: "3.7"
  services:
    db:
      image: mysql
      volumes:
       - data:/var/lib/mysql
  
  volumes:
    data:
      driver_opts:
        type: none
        device: /usr/local/opt/mysql/mywebsite.com
        o: bind  
  </code></pre>
  
  <p>Here's the result of <code>docker-compose up</code>:</p>
  
  <pre><code>$ docker-compose up
  Creating volume "mycontainer_data" with default driver
  Recreating 45bc03b2c674_mycontainer_db_1 ... error
  
  ERROR: for 45bc03b2c674_mycontainer_db_1  Cannot create container for service db: error while mounting volume with options: type='none' device='/usr/local/opt/mysql/mywebsite.com' o='bind': no such file or directory
  
  ERROR: for db  Cannot create container for service db: error while mounting volume with options: type='none' device='/usr/local/opt/mysql/mywebsite.com' o='bind': no such file or directory
  ERROR: Encountered errors while bringing up the project.
  </code></pre>
  
  <p>Instead of <code>type: none</code>, I have also tried <code>type: volume</code> and <code>type: bind</code>, but I got the same error.</p>
  
  <p>The directory clearly exists:</p>
  
  <pre><code>$ ls -al /usr/local/opt/mysql/
  ...
  drwxr-xr-x   2 cameronhudson  staff      64 Jun 10 10:32 mywebsite.com
  ...
  
  </code></pre>