Skip to content

docker-entrypoint.sh: executable shell script test is unreliable #1108

Closed
@mhw

Description

@mhw

docker-entrypoint.sh uses a .sh file's executable mode to decide whether to source or exec the shell script. Due to a long-standing issue on Docker Desktop for macOS when VirtioFS or gRPC FUSE are used all files mounted into the container from the host are executable according to test -x even if the executable bit is not set, so this test is unreliable. As a result non-executable scripts in /docker-entrypoint-initdb.d are executed, giving a Permission denied error and the script does not run.

Although this really needs fixing in Docker Desktop, it's potentially going to lead to hard-to-diagnose issues in Postgres initialisation so I thought it at least worth reporting here for visibility. A possible workaround for the Docker issue could be to use stat and grep: something like if stat -c '%A' "$f" | grep -q '^-..x'; then ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions