I was trying to setup a command using Yarn to create directories, build my Docker images and then launching docker-compose up .

I added a start script in my package.json to execute a shell script:

"scripts": { "start": "./start-docker.sh", ... }

This is the start-docker.sh:

#!/bin/bash mkdir -p volumes/mysql volumes/wordpress docker-compose build docker-compose up

It didn't work at first because my containers had no rights to access the created directories.

I then added this line after the creation of the directories in order to give full permissions to containers:

sudo chmod -R 777 volumes

But as you can see, this command requires to be executed using sudo. This means that executing the yarn start command asks for a password, thing I didn't want.

I get rid of the shell script and used yarn scripts only:

"scripts": { "prestart": "mkdir -p volumes/mysql volumes/wordpress && docker-compose build", "start": "docker-compose up", ... }

Surprisingly enough it worked, but I don't understand why.. do you guys have any idea?