Description
I've got a docker-compose file where I include the following:
services:
postgres-12:
image: postgres:12-alpine
user: root
volumes:
- "${PWD}/init-script.sh:/docker-entrypoint-initdb.d/init-script.sh"
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.