DEV Community

Discussion on: Multiple Postgres databases in a single Docker container

Collapse
 
dariansampare profile image
Darian Sampare

Anyone ever run into permission issues running the script?

For example:

server started

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/create-multiple-postgres-databases.sh

/usr/local/bin/docker-entrypoint.sh: /docker-entrypoint-initdb.d/create-multiple-postgres-databases.sh: /bin/bash: bad interpreter: Permission denied

Collapse
 
resulyrt93 profile image
Resul Yurttakalan

I figure out this problem with change volume config. Don't attach whole /docker-entrypoint-initdb.d directory as volume. Then not permitted a directory copied to container. Solution was add all files one by one. like below;

volumes:
      - ./db_init/db_init.sh:/docker-entrypoint-initdb.d/db_init.sh 
Enter fullscreen mode Exit fullscreen mode
Collapse
 
dariansampare profile image
Darian Sampare

Well... in case any other poor soul stumbles onto this problem, you have to set the script as executable because Docker copies over permissions...

chmod +x pg-init-scripts/create-multiple-postgres-databases.sh
Enter fullscreen mode Exit fullscreen mode
Collapse
 
danicunhac profile image
Daniel Costa

I also created an account just to thank you

Collapse
 
pederfosse profile image
PederFosse

I created an account just to thank you

Thread Thread
 
dariansampare profile image
Darian Sampare

😂 Your welcome!

Collapse
 
ditharahma12 profile image
Rahmaditha

i've already done that. but still no database created

Thread Thread
 
danicunhac profile image
Daniel Costa

You'll need to then run docker-compose up -d again and if needed, create your new database from an sql script.

Collapse
 
ykachube profile image
mr Robot

I also created an account just to thank you