You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm expecting that is will run this script as root, but the very first line of the script is:
apk update
And this results in:
postgres-12_1 | ERROR: Unable to lock database: Permission denied
postgres-12_1 | ERROR: Failed to open apk database: Permission denied
I've seen this issue: #321 and it seems to suggest, along with the documentation on the image page, that I should be able to run scripts as the user I specify. However, it doesn't seem to be respecting this. I can run these commands without issue if I start the container without mounting the script and then ssh in to get a terminal prompt, but I want them to run automatically on first startup. The purpose is to download and install an extension via its makefile so that I don't have to manually install it every time I spin up a new db. So the script contains some apk commands to update and get dependencies (e.g. gcc) to install the extension.
The text was updated successfully, but these errors were encountered:
Additionally, as of docker-library/postgres#253, these initialization scripts are run as the postgres user (or as the "semi-arbitrary user" specified with the --user flag to docker run;
# setup data directories and permissions (when run as root)
docker_create_db_directories
if [ "$(id -u)"='0' ];then
# then restart script as postgres user
exec gosu postgres "$BASH_SOURCE""$@"
fi
Edit: You should probably just be using a Dockerfile to create a custom image FROM postgres:[version] with the needed extension since starting a new container with an already initialized database will result in no extension.
I've got a docker-compose file where I include the following:
I'm expecting that is will run this script as
root
, but the very first line of the script is:And this results in:
I've seen this issue: #321 and it seems to suggest, along with the documentation on the image page, that I should be able to run scripts as the user I specify. However, it doesn't seem to be respecting this. I can run these commands without issue if I start the container without mounting the script and then ssh in to get a terminal prompt, but I want them to run automatically on first startup. The purpose is to download and install an extension via its makefile so that I don't have to manually install it every time I spin up a new db. So the script contains some apk commands to update and get dependencies (e.g. gcc) to install the extension.
The text was updated successfully, but these errors were encountered: