Closed
Description
I am using postgres:17
image, and in my docker-compose.yml
file I have added:
volumes:
- pgdata:/var/lib/postgresql/data
- ../init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
The ../init-db.sh
does not have the executable mode on the host:
-rw-r--r--@ 1 myuser staff 2218 14 Mar 14:02 init-db.sh
so it is expected to be sourced, but instead the container initialization is trying to execute it
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init-db.sh
/usr/local/bin/docker-entrypoint.sh: line 174: /docker-entrypoint-initdb.d/init-db.sh: Permission denied
I have created a container to check what is going on
% docker run --rm -it -e POSTGRES_HOST_AUTH_METHOD=trust -v ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh postgres:17 bash
root@f7ca7450b9d2:/# cd docker-entrypoint-initdb.d/
root@f7ca7450b9d2:/docker-entrypoint-initdb.d# ls -la
total 12
drwxr-xr-x 1 root root 4096 Mar 17 13:04 .
drwxr-xr-x 1 root root 4096 Mar 17 13:04 ..
-rw-r--r-- 1 root root 2218 Mar 14 14:02 init-db.sh
root@f7ca7450b9d2:/docker-entrypoint-initdb.d# [ -x init-db.sh ] && echo $?
0
root@f7ca7450b9d2:/docker-entrypoint-initdb.d#
so strangely the test [ -x init-db.sh ]
is failing: it should have returned 1
!
Old issues related to this: #490 #452
The expected behavior is for the init-db.sh
script to be sourced, not executed.
Metadata
Metadata
Assignees
Labels
No labels