Unable to create open site_config.json: permission denied

I’m Installing a new instance of ERPNext with docker, and I mounted a volume that points at:

/home/frappe/frappe-bench/sites/localhost

However, workers and node complain about not being able to create open site_config.json because of permission denied.

The stack looks to be working pretty well so far, although I’m concerned about those workers and node complaining… Why those processes need access to site_config.json and what issues might that have in the long run?

For multi-tenancy, they need the hostname

Maybe its an issue with the docker setup.

Right now I’m using a modified version of donysukardi repo (I also started a PR his alpine script which wouldn’t build). The file site_config.json is actually where it’s supposed to be and where workers are looking, and its contents are those set and working well with the following permissions:

-r--r----- 1 frappe frappe 603 Jan 17 09:39 site_config.json

Here is what bench config auto_update on returns. Spoiler: although I chmod a+rwx site_config.json just for fun, the result doesn’t change.

Traceback (most recent call last):
  File "/usr/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/bench-repo/bench/commands/config.py", line 16, in config_auto_update
    update_config({'auto_update': state})
  File "/home/frappe/bench-repo/bench/config/common_site_config.py", line 41, in update_config
    put_config(config, bench_path=bench_path)
  File "/home/frappe/bench-repo/bench/config/common_site_config.py", line 35, in put_config
    with open(config_path, 'w') as f:
IOError: [Errno 13] Permission denied: './sites/common_site_config.json'

If I run bench from the “app” container the update script complains it cannot find redis server running, which it is and I can successfully ping all three redis containers from within the app, socketio, cache and queue. Here is what happens when I call bench update for example:

/bin/sh: redis-server: not found
Traceback (most recent call last):
  File "/usr/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/bench-repo/bench/commands/update.py", line 31, in update
    patches.run(bench_path='.')
  File "/home/frappe/bench-repo/bench/patches/__init__.py", line 21, in run
    result = execute(bench_path)
  File "/home/frappe/bench-repo/bench/patches/v3/redis_bind_ip.py", line 10, in execute
    generate_config(bench_path)
  File "/home/frappe/bench-repo/bench/config/redis.py", line 34, in generate_config
    "redis_version": get_redis_version(),
  File "/home/frappe/bench-repo/bench/config/redis.py", line 54, in get_redis_version
    version_string = subprocess.check_output('redis-server --version', shell=True).strip()
  File "/usr/lib/python2.7/subprocess.py", line 219, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'redis-server --version' returned non-zero exit status 127

This is interesting… As I found out, manually setting permissions do not work (for some reason I’m not yet able to understand) because they won’t get through subsequent docker-compose restart. They get back at:

-r--r----- 1 frappe frappe 603 Jan 17 13:30 site_config.json

I also found an open issue with dockerize about this. @rmehta do you know how to work around this issue maybe?

Solved :tada: As easy as updating dockerize to v0.3.0 then 640 permissions would carry through!

Now there’s still this redis server not found mistery to solve, but I’m going to open a new topic about it right now, thank you @rmehta