postgres icon indicating copy to clipboard operation
postgres copied to clipboard

Behaviour change between 9.5.20 and 9.5.21?

Open vpzomtrrfrt opened this issue 6 years ago • 48 comments

When running docker run --rm postgres:9.5.20-alpine, the database successfully starts up, but with docker run --rm postgres:9.5.21-alpine, I get this output instead:

Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD for the superuser. Use
       "-e POSTGRES_PASSWORD=password" to set it in "docker run".

       You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections
       without a password. This is *not* recommended. See PostgreSQL
       documentation about "trust":
       https://www.postgresql.org/docs/current/auth-trust.html

Is this an expected change?

vpzomtrrfrt avatar Feb 14 '20 22:02 vpzomtrrfrt

Based on 42ce7437ee it seems like it's intentional, but I find it odd to change something like that on a minor release

vpzomtrrfrt avatar Feb 14 '20 22:02 vpzomtrrfrt

I just observed the same issue when bumping 9.6.16 => 9.6.17.

aengelberg avatar Feb 14 '20 22:02 aengelberg

See also #658, the PR that seems to have introduced this

vpzomtrrfrt avatar Feb 14 '20 23:02 vpzomtrrfrt

We were convinced to make it more secure by default and were aware that this would break some users. Apologies for breaking changes. :bowing_man: We felt that the increased security out-weighed the breakage. See https://github.com/docker-library/postgres/pull/658 and https://github.com/docker-library/postgres/pull/580.

If you know that you want to be insecure (i.e. any one can connect without a password from anywhere), then POSTGRES_HOST_AUTH_METHOD=trust is how you opt in to that.

We really recommend setting a password and it was really a bad decision by me in the beginning to continue to allow running the database without a password (https://github.com/docker-library/postgres/issues/31#issuecomment-63396053 & #36)

yosifkit avatar Feb 14 '20 23:02 yosifkit

I wish a breaking change was not pushed out on a Friday. This broke our CI/CD pipeline, which I had to fix on a Saturday.

bxparks avatar Feb 15 '20 17:02 bxparks

Where in a CI/CD pipeline does one place those lines -e POSTGRES_PASSWORD=password or POSTGRES_HOST_AUTH_METHOD=trust ?

CloudArchipelago avatar Feb 16 '20 05:02 CloudArchipelago

As always emotions fly high when a breaking change is introduced, causing work for others ;)

I appreciate the effort that you put into maintaining this image!

Maybe one can put the fix to add "POSTGRES_HOST_AUTH_METHOD=trust" somewhere more prominent. I get it that its part of the docker output when you start the image, yet sadly not if you start it with "-d". Then you are just wondering why the next docker command complains that the database is not up ;)

chickahoona avatar Feb 16 '20 07:02 chickahoona

@CloudArchipelago: It depends on what pipeline you are using. The two that I'm familiar with is GitHub and BitBucket:

  • For GitHub, I think you put the POSTGRES_HOST_AUTH_METHOD=trust in the env section shown here: https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml
  • We use BitBucket, and it goes in the environment section shown here: https://community.atlassian.com/t5/Bitbucket-questions/How-do-I-use-Postgres-in-Bitbucket-Pipelines/qaq-p/461910

(Of course, these articles and examples will need to be updated, since they no longer work as shown.)

I don't understand exactly how these pipelines actually configure and start the Postgres service in docker. So I don't know where the -e POSTGRES_PASSWORD=password would go.

And to be honest, I don't fully understand exactly what POSTGRES_HOST_AUTH_METHOD=trust does either since it's the first time I'm seeing it. I can probably figure it out in a few hours, but y'know, it's the long weekend. I got family to take care of, out of town guests visiting, housework to do, shopping to do, don't got time to spend on this...

bxparks avatar Feb 16 '20 19:02 bxparks

Was or is there consideration to switch to something like semantic versioning? If that was the case then this change, given it's intentional and a breaking changes, would cause a major revision change and everyone could deal with it accordingly. If such a change comes through not as a major, not even as a minor but merely as a patch release (z in x.y.z), then it is highly surprising and that is what trips up processes. Just putting it out there for consideration.

ManfredLange avatar Feb 17 '20 03:02 ManfredLange

Tried @bxparks proposed workaround for our CircleCI build (we use Github) and it worked. Simply add POSTGRES_HOST_AUTH_METHOD: trust.

- image: circleci/postgres:9.6-postgis-ram
       environment:
          POSTGRES_USER: 'username'
          POSTGRES_HOST_AUTH_METHOD: trust

kennethteh90 avatar Feb 17 '20 04:02 kennethteh90

We were just burnt by this change and would give a big +1 to adopting semver to help mitigate this in the future.

However, I'm not posting just to pile on about semver, I have one other thing I'd like to point out. When our CI pipelines starting running with this newer container image (without POSTGRES_HOST_AUTH_METHOD or POSTGRES_PASSWORD) set the postgres container looked like it was coming up and staying up correctly. Because it wasn't clear the postgres container was the issue we spent a lot of time and effort looking in the wrong place.

In future, if a change is made where the database effectively doesn't work, the container should not just sit there happily doing nothing when it's actually broken. Had the postgres container been more noticeably broken we could have saved most of the time and effort we spent looking in the wrong place for the cause of the issue.

As a slight aside, is there an official we can monitor to know about future significant or breaking changes to this container in future?

Nadock avatar Feb 17 '20 06:02 Nadock

Same here, broken our CI and local development

scaytrase avatar Feb 17 '20 07:02 scaytrase

Just change the PostgreSQL image to a more specific version, not the latest. E.g. changing to 9.5.18 fixed the problem for me

Wapiti08 avatar Feb 17 '20 09:02 Wapiti08

Can I also agree that some more documentation on this would have been great. Perhaps a changes section on docker hub? Our local CI broke due to this and while the change is sensible and fixing the issue important some more sign posting would have been great.

cookejames avatar Feb 17 '20 14:02 cookejames

How about making it a major release then instad of defining it a patch release? It's a breaking change after all.

rockymontana avatar Feb 17 '20 15:02 rockymontana

This is not a change you want to make on a minor release, you morons... That's why semver exists.

Edit: you can downvote this comment all you want. Hell, please, go on and use all the available emojis. I couldn't care less. I hate when people randomly decide to make breaking changes without issuing warnings, which then makes me waste my time figuring out who-broke-what-and-where.

This ins't something that anybody asked for, and making the change in that way was absolutely the no-no way. drops mic

alexandernst avatar Feb 17 '20 16:02 alexandernst

"Moron" he said ... not sure why you have to lose your manners ... @alexandernst Isn't it your fault that you did not pin the version?

Just about the versioning. The docker tag for example "9.5.21" means "Postgres 9.5", with Docker Hub Release 21. So the docker images are not semver versioned and therefore it is everyones duty to pin the exact version if he cannot live with something breaking now and then ...

One could introduce semver, producing docker tags like "9.5.1.2.3" but I am pretty sure that is not what you want. As one could assume this kind of versioning and maintaining all releases is extremely time consuming and people would still not pin "9.5.1.2.3" and instead use "9.5"...

chickahoona avatar Feb 17 '20 17:02 chickahoona

Oh, it my fault that now we're introducing breaking changes in minor versions and without issuing a proper notice? Sure :)

PD: How about no?

alexandernst avatar Feb 17 '20 17:02 alexandernst

to be honest, it would make more sense not to use something that looks a little like semver if you aren't going to follow its standards (which is totally understandable choice).

perhaps 9.5-build.21 would be a better approach to maintain semver but keep the releasing mechanism?

nodefortytwo avatar Feb 17 '20 17:02 nodefortytwo

postgres:9.5.21 contains PostgreSQL version 9.5.21: https://www.postgresql.org/docs/9.5/release-9-5-21.html

tianon avatar Feb 17 '20 17:02 tianon