Permissions problem

Hi guys,

I have this bash script I’m trying to run to create multiple databases but when running my docker-compose file I get a permission error:
/usr/local/bin/docker-entrypoint.sh: /docker-entrypoint-initdb.d/init-multiple-dbs.sh: /bin/sh: bad interpreter: Permission denied

I tried to give write permissions to init-multiple-dbs.sh:
chmod +x init-multiple-dbs.sh

Didn’t work… I’m on a Mac and this is being run using docker-compose:
volumes:
- ./pg-init-scripts/init-multiple-psql-dbs.sh:/docker-entrypoint-initdb.d/init-multiple-psql-dbs.sh

Any idea what I can do to fix this?

Hi @Xavier.Vieira

Have you crafted the script correctly?

First line must be as follows - there must be nothing above it

#!/bin/sh

Line endings should be LF (which is the default on macs anyway)

Script should be executable and directory it is in should also have appropriate permissions if not executing script as root.

Thanks for the answer.

Nothing seems to work unfortunately.

  • First line is correct (just copy pasted to confirm)
  • Line endings are LF (checked on editor)
  • Folder has permissions drwxr-xr-x
  • File has permissions -rwxr-xr-x

:confused:

You can post the script here so we can look at it. Remember to enclose in triple backtick to preserve formatting

so it looks like this

may be you should try login root user !!