postgis / docker-postgis

Docker image for PostGIS
https://hub.docker.com/r/postgis/postgis/
MIT License
1.37k stars 464 forks source link

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

Open sherwynsaul opened 1 year ago

sherwynsaul commented 1 year ago

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.

Laro88 commented 1 year ago

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.