docker-postgis icon indicating copy to clipboard operation
docker-postgis copied to clipboard

No way to run commands that need root access from `/docker-entrypoint-initdb.d`

Open sherwynsaul opened this issue 2 years ago • 1 comments

I need to create an ssh tunnel, before I can get a dump of a dev db. This involves installing openssh and running ssh. While I can do the installs and possibly create the tunnel from the Dockerfile.

I say possibly because the exact same commands that work if I start container run through the bash shell, do not work if I run them from Dockerfile. There is an invalid format error on the private key; the exact same private key the works if I run under bash from a running container. But that is another issue.

Anyway, I am pretty sure I am not the only one who has gone through this. It seems years ago this was not an issue as we could run scripts as root or at least commands as root in the startup scripts in ./docker-entrypoiint-initdb.d, however this is not the case anymore. I figure there is some work around or best practice. But I have not been able to find it.

I have also posted on stackoverflow about this.

https://stackoverflow.com/questions/74855870/open-ssh-tunnel-during-postgis-docker-build?noredirect=1#comment132105437_74855870

Seems the closest information I have found to what I am trying to do is https://github.com/docker-library/postgres/issues/973

And it seems like the advise is to create a custom Image from postgres image. Is this still the recommendation? Just seems like there should be a way to run root commands in a startup script.

Any help would be greatly appreciated.

sherwynsaul avatar Dec 20 '22 02:12 sherwynsaul

I had the same problem as you @sherwynsaul, however it worked for me using the postgis/postgis:15-3.3-alpine

Sidenote, I was using mdillons postgis distribution before.

Laro88 avatar Jan 02 '23 14:01 Laro88