Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-entrypoint-initdb.d bad interpreter: Permission denied

Hi I a using postgres docker-compose in my application. When I am trying to run it on my local machine (macOS Big Sur) I am getting below error and postgres container exited.

 /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/postgres-ssl.sh
/usr/local/bin/docker-entrypoint.sh: /docker-entrypoint-initdb.d/postgres-ssl.sh: /bin/bash: bad interpreter: Permission denied

Below is my docker-compose

postgres:
build:
  context: ./setup/postgres
  dockerfile: ./Dockerfile
command:
  -c ssl=on -c ssl_cert_file=/var/lib/postgresql/ssl/certs/server.crt
  -c ssl_key_file=/var/lib/postgresql/ssl/certs/server.key
  -c ssl_ca_file=/var/lib/postgresql/ssl/certs/root.crt
ports:
  - '5432:5432'
volumes:
  - ./setup/postgres/scripts:/docker-entrypoint-initdb.d
environment:
  - POSTGRES_HOST_AUTH_METHOD=trust

Am I missing any steps here?

like image 538
ppb Avatar asked Jul 21 '21 21:07

ppb


Video Answer


1 Answers

I ended up running into this same issue. For anyone who faces this, you need to give execution permission to your script file, since Docker copies over permissions:

chmod +x your/script.sh

In my case the issue msg was:

/opt/bitnami/scripts/libpostgresql.sh: /docker-entrypoint-initdb.d/my-initdb.sh: /bin/bash: bad interpreter: Permission denied

Then I gave execution permission to my-initdb.sh and it worked nicely

like image 171
Thales Valias Avatar answered Oct 20 '22 22:10

Thales Valias