title: How to name a volume using a docker-compose.yml file?
body: <p>I'm new to Docker and I'm trying to find out how to set the name of the created data volume. Currently the directory is automatically named as a long hash under /var/libs/docker which is far from user friendly.</p>
  
  <p>I'm attempting to set up a development environment for MODX as shown here:
  <a href="https://github.com/modxcms/docker-modx" rel="noreferrer">https://github.com/modxcms/docker-modx</a></p>
  
  <p>Currently my docker-compose.yml file is as follows:</p>
  
  <pre><code>web:
    image: modx
    links:
      - db:mysql
    ports:
      - 80:80
  db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: example
    ports:
      - 3306:3306
    command: mysqld --sql-mode=NO_ENGINE_SUBSTITUTION
  myadmin:
    image: phpmyadmin/phpmyadmin
    links:
      - db:db
    ports:
      - 8080:8080
  </code></pre>
  
  <p>This works perfectly but I'm unsure as to how to name the data volume that I would edit directly with my IDE.</p>
  
  <p>(As a side question, does it have to be created under /var/libs/docker ? Or is there a way of setting it to a directory in my home folder?)</p>
  
  <p><strong>Update:</strong>
  Thanks to the help from @juliano I've updated my docker-compose.yml file to:</p>
  
  <pre><code>version: '2'
  
  services:
      web:
        image: modx
        volumes: 
          - html:/home/muzzstick/dev/modxdev
        links:
          - db:mysql
        ports:
          - 80:80
      db:
        image: mysql
        environment:
          MYSQL_ROOT_PASSWORD: example
        ports:
          - 3306:3306
        command: mysqld --sql-mode=NO_ENGINE_SUBSTITUTION
      myadmin:
        image: phpmyadmin/phpmyadmin
        links:
          - db:db
        ports:
          - 8080:8080
  
  volumes:
      html:
          external: false
  </code></pre>
  
  <p>Unfortunately this seems to stop the web container from running. 
  db and myadmin containers show they're running ok.
  There weren't any errors... if I type <code>docker start docker_web_1</code> it appears to start but <code>docker ps -a</code> shows it exited as soon as it started.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>Running <code>docker-compose up -d</code> appears to run without issue. But then as you can see below, the web container exits as soon as it's created.</p>
  
  <pre><code>    CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS                     PORTS                            NAMES
  a1dd6d8ac94e        modx                    "/entrypoint.sh apach"   10 seconds ago      Exited (1) 5 seconds ago                                    docker_web_1
  ee812ae858dc        phpmyadmin/phpmyadmin   "/run.sh phpmyadmin"     10 seconds ago      Up 5 seconds               80/tcp, 0.0.0.0:8080-&gt;8080/tcp   docker_myadmin_1
  db496134e0cf        mysql                   "docker-entrypoint.sh"   11 seconds ago      Up 10 seconds              0.0.0.0:3306-&gt;3306/tcp           docker_db_1
  </code></pre>
  
  <p><strong>Update 3</strong>
  OK the error logs for this container shows:</p>
  
  <pre><code>error: missing MODX_DB_HOST and MYSQL_PORT_3306_TCP environment variables
  Did you forget to --link some_mysql_container:mysql or set an external db
  with -e MODX_DB_HOST=hostname:port?
  </code></pre>
  
  <p>This error appears to be originating from <a href="https://github.com/modxcms/docker-modx/blob/master/apache/docker-entrypoint.sh#L15-L20" rel="noreferrer">https://github.com/modxcms/docker-modx/blob/master/apache/docker-entrypoint.sh#L15-L20</a></p>
  
  <p>Could it be something like linking is handled differently in docker-compose version 2?</p>