Docker Postgres Jest: EACCESS Permission denied postgres-data

tanut aran
1 min readDec 7, 2020

--

There are time when the docker volume can be a problem.

Especially when running watch e.g. jest --watch throws:

Error: EACCES: permission denied, scandir '/home/development/myproject/postgres-data'

Then we see the problem

drwxr-xr-x.   2 tanut tanut 4.0K Dec  4 21:28 db.sql
drwx------. 19 avahi tanut 4.0K Dec 7 10:27 postgres-data

Problem:

  1. If we do chgrp or chown, Docker cannot read this file anymore
  2. Docker cannot run but when elevated with sudo , the command try to revert the change.

Solution:

One way is to mount the volume somewhere outside the repos.

Easier way is to make jest ignore this path by editing jest.config.json file.

This file is loaded by default. No need to specified in jest command.

// jest.config.json
{
"testRegex": "((\\.|/*.)(spec))\\.js?$",
"clearMocks": true,
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/node_modules/",
"postgres-data",
"db.sql"
],
"watchPathIgnorePatterns": [
"/node_modules/",
"postgres-data",
"db.sql"
]
}

Leave me some comment if this save your time.

Cheers!

--

--

tanut aran
tanut aran

Written by tanut aran

Co-founder and Coder at work !

No responses yet