New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR: required extension "postgis" is not installed #2
Comments
Yeah, me too. But I can create extension through pgadmin though. I don't know how extensions are working in postgres, so don't really know how can we fix this. |
Hey guys. I just saw this report. For some reason this repo wasn't on my watch list 😬 I'm swamped with a project at work right now, but I'll look into this when I have some time. @Starefossen Off the top of my head, my guess is that the init script you're adding is running before the If that is the issue, then you should be able to work around it by naming your initdb script something lexicographically after |
I also thought that my script was running before yours. And it was. So I changed the name and I am sure that it was executed after yours, but still haven't worked. |
Also if you'll figure out the way to create extensions in init scripts, then what extensions should be created can be configured via environment_variables. |
Here is output of my docker build. ostgreSQL stand-alone backend 9.3.5 backend> statement: UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis' backend> ERROR: type addbandarg[] does not exist backend> statement: CREATE EXTENSION IF NOT EXISTS postgis_topology; ERROR: required extension "postgis" is not installed |
I'm getting the same result when I rename my init script to run after the postgis init script. The full docker run log is available here. |
@Starefossen Could you try using I think the issue is that the Postgis stuff is only getting installed into I was able to make a little progress here I think: https://gist.github.com/md5/c0de85617891e1c17fcd |
First, thanks a lot for taking your time to help me with this issue! With your suggested alternations to the CREATE DATABASE query I got this error:
Then, I removed the
I tried to run my original CREATE DATABASE query through |
You don't need to run As for the other error, I think you need to change |
FYI, I just added It's building on the Docker Registry now. |
I've created a PR over at #3 to add a "Usage" section to the |
If I understand correctly to use postgis I need to extend your image? I mean, you're saing "Use template_postgis for you database", but the database is created in official postgres image without any lines of code from me. I think that we should be ably to use your images in that way also or it wouldn't make much sense to use it at all. The database name shouldn't be hardcoded in init script or dockerfile, It should be created automatically and be ready to use after building the image. What do you think? |
@purpleP I didn't mean to imply that. I was only providing the derived image instructions because that seemed to be what @Starefossen was trying to achieve. You should be able to create a PostGIS-enabled database in the normal way using this image. Furthermore, I think it would be reasonable for the default database created by the container to be PostGIS-enabled as you suggest. However, my investigation has found that creating a PostGIS-enabled database in Stepping back a bit, it seems I was a bit hasty in this comment. When I created this image, I did it for the purpose of running iNaturalist locally, not to act as a general-purpose PostGIS image. As such, I didn't really read up on PostGIS or the current state of Postgres before creating it. It turns out that my comment about The actual problem with Dockerfile FROM postgres:9.4
# Add init script
ADD initdb-foo.sh /docker-entrypoint-initdb.d/foo.sh initdb-foo.sh
When I do this, I get the error |
md5, Yes, I've posted bugreport about addbandargs[] not working in single-user mode to postgresql team. |
Great! You saved me the trouble of doing that later today. Do you have a URL for the bug report?
|
@purpleP I took a look at pgsql-bugs and didn't find any mention of |
I got some time to join Long story short, there is code in Postgres that explicitly avoids creating implicit array types in
|
This is basically the exact conclusion I came to when I started digging into single-user mode more to improve our entrypoint code to be more flexible. 😞 |
For the record, MySQL's |
One of the suggestions on IRC was to start up the server on an alternate port to perform the initialization before switching to the actual port. At first I balked at this idea, but perhaps it's not that bad... Let's look at the current UX:
If the script in step 1 is a long-running one, the user will get Let's say that instead of doing the mechanics of step 1 using The big drawback of this approach is that the BTW, this same sort of approach would also work for the MySQL case I believe. |
I'd also say that this is just one more instance of the general problem of differentiating when a Docker container is started v. when it's actually available to do its job. |
Looks like there are a fair number of public repos on Github using the Perhaps it's worth nudging some more to get Whether or not it would be backported to earlier Postgres versions is of course another question, one which I assume would be answered in the negative. |
Here's some discussion related to container readiness v. startedness: moby/moby#7445 |
md5, I thought about starting postgres as a deamon process in CMD command and then execute psql commands. What do you think about that? |
Are you just talking about using That works fine for creating things after the container is started, but not if you want them to be created before Postgres starts responding to requests on port 5432. |
Could we start the Postgres deamon on an alternate port during the bootstrap? |
@Starefossen yes, I think so. That's what I was getting at in this comment: #2 (comment) The only issue with that is that all the existing |
I looked into the IsUnderPostmaster usage (see the pgsql-bugs thread). This one case regarding array types is the only one that actually changes the behavior of SQL commands. I think a strong case can be made that it should be fixed. |
For anyone interested, I've started a thread about this issue on the |
It should be possible to make this work now. The |
Hi all. I pushed a branch with a proposed update to add PostGIS to the default database created by the |
Good job @md5 👏🏼 |
Thanks @Starefossen! 👍 Any chance you've got some time to test it out? |
https://github.com/purpleP/docker-postgis That's how I do it. Maybe someone would use it too. We actually can generalize that and instead of creating postgis extensions execute any sh script like they do in docker postgis repository. |
@purpleP Did you take a look at #11? I'm using the It looks like you instead forked |
@md5 I did exactly that, because guys from postgres doesn't recommend to use single user mode for anything except recovery from failures feature. I did look at 11, but I haven't tried it yet. If it works, then why haven't you've done that earlier? |
Because I wanted this image to be based on the That merge was a breaking change for users, quite a number of whom complained about it, so I can understand (and supported) the caution that went into making that change. I personally still hoped the Postgres folks would change their minds and fix |
@md5 Oh, I didn't know about this change in docker library. That's a great news. |
@md5 Hi again. I finally had the time to check your new branch. after building and running your image I've tried to do the following - execute CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology; and got following errors. ERROR: PostGIS is already installed in schema 'public', uninstall it first ERROR: PostGIS is already installed in schema 'public', uninstall it first I conclude from that that postgis is indeed installed right after starting database, but I'm not sure because usually this sql gives me another error (if postgis installed (and I do that via exactly this sql))- something like ERROR already exists. |
@md5 I can also confirm that our django app that uses postgis seems to works fine. |
@purpleP Glad to hear your app works. Out of curiosity, what command did you use to start the container? |
@md5 docker run -itd -p 5432:5432 -e POSTGRES_PASWWORD=pass -e POSTGRES_USER=user some_postgis. |
I'm assuming Assuming you're connecting to the I'm still curious about the difference in the error message you mention, though. I'd like to rule out some sort of mistake on my part before I merge #11. |
@md5 You are assuming right. Well, I don't know why are error is different, but we can try to solve that. |
@md5 For one thing you are creating template database, right? And I usually just executing create extension sql |
@purpleP Creating |
I just pushed another commit (deb7d56) to #11 after doing some more debugging. Turns out there were all kinds of issues with my I also made changes to the initialization for 9.0 to add raster support (cf. f705708). I believe everything should be working properly now. |
I just merged #11. I think this should be fixed. @Starefossen please reopen if you don't think that's the case. Others can open new issues as needed (hopefully there won't be any). |
fix ssl conf
Host OS: Ubuntu 14.04
Docker version: 1.3.3
Dockerfile:
initdb-foo.sh:
I get the following output when I run my Dockerfile:
The text was updated successfully, but these errors were encountered: