title: Permissions to created directories using Yarn
body: <p>I was trying to setup a command using <strong>Yarn</strong> to create directories, build my Docker images and then launching <code>docker-compose up</code>.</p>
  
  <p>I added a <em>start</em> script in my <code>package.json</code> to execute a <strong>shell script</strong>:</p>
  
  <pre><code>"scripts": {
    "start": "./start-docker.sh",
    ...
  }
  </code></pre>
  
  <p>This is the <strong>start-docker.sh</strong>:</p>
  
  <pre><code>#!/bin/bash
  
  mkdir -p volumes/mysql volumes/wordpress
  
  docker-compose build
  
  docker-compose up
  </code></pre>
  
  <p>It didn't work at first because my containers had no rights to access the created directories.</p>
  
  <p>I then added this line after the creation of the directories in order to give full permissions to containers:</p>
  
  <pre><code>sudo chmod -R 777 volumes
  </code></pre>
  
  <p>But as you can see, this command requires to be executed using <em>sudo</em>. This means that executing the <code>yarn start</code> command asks for a password, thing I didn't want.</p>
  
  <p>I get rid of the <em>shell script</em> and used <strong>yarn scripts only</strong>:</p>
  
  <pre><code>"scripts": {
    "prestart": "mkdir -p volumes/mysql volumes/wordpress &amp;&amp; docker-compose build",
    "start": "docker-compose up",
    ...
  }
  </code></pre>
  
  <p>Surprisingly enough it worked, but I don't understand why.. do you guys have any idea?</p>