docker-gitlab: Gitlab 16 incompatible with PostgreSQL 12, requires >=13
docker-compose.yml contained in the 16 release uses sameersbn/postgresql:12-20200524 as a PostgreSQL container. When starting the containers, we get following error:
You are using PostgreSQL 12.3 for the ci database, but this version of GitLab requires PostgreSQL >= 13.
Please upgrade your environment to a supported PostgreSQL version.
See https://docs.gitlab.com/ee/install/requirements.html#database for details.
Despite the message, Gitlab itself appear to work at a cursory glance, but it will probably cause problems further down the line.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 16
- Comments: 30 (8 by maintainers)
We’ll provide a workaround. But this will take some time.
I just updated the PostgreSQL version in my GitLab Docker environment. I went from using the image ‘sameersbn/postgresql:12-20200524’ to ‘sameersbn/postgresql:14-20230628’, and then upgraded again to ‘sameersbn/postgresql:15-20230628’. During each transition, I performed a Docker Compose up.
PostgreSQL seamlessly detected the need for an upgrade when I switched to the newer versions, and I’m pleased to report that the entire process went smoothly without any issues.
So, to avoid any problem seems to be a good idea to upgrade from 12 to 14 and then 15.
How I did it - or very inofficial instructions for Docker Compose and Postgres image from Bitnami.
Credits to @f-io.
docker compose down. Make sure you are using the newest software with the new syntax; without the-between docker and compose.postgresql:topostgresql-old:indocker-compose.ymlfile.docker-compose.ymlfile:postgresql-old:docker compose up -d postgresql-old.sudo bash -c 'docker compose exec postgresql-old /bin/bash -c "PGPASSWORD=*** pg_dump --username gitlab gitlabhq_production" > ./gitlab_dump_.sql'. Notice the space at the beginning of the command. On some distros this will prevent the command saved to the bash history. Useful because of the password.docker compose down.sudo mv volume_postgresql volume_postgresql_old.docker compose up -d postgresql.###from newvolume:section indocker-compose.ymlfile.docker compose down.docker compose up -d postgresql.docker compose exec -T postgresql /bin/bash -c "PGPASSWORD=*** psql --username gitlab gitlabhq_production" < ./gitlab_dump_.sqldocker compose down.docker compose upand see if it works…docker compose up -d.@sachilles a good first step would be - if you have the permissions needed at all, if not, the discussion on that topic is probably moot - to provide a PQ13 version of
sameersbn/postgresqlthat people could test drive with a manual upgrade process. If that isn’t possible (I’m not sure the original author is still around at all), we should probably discuss the best part forward. A fork, maybe ?It’s probably not very productive if people report back on their issues with random hand rolled deployments of official PG13 images and/or custom patched/upgraded versions of
sameersbn/postgresqland will just end up muddling the discussion.We moved to official postgres docker image and also used pg_dump. Database dump ~6G, almost 8y of collected garbage.
Just make sure that the required extensions are available in your new database.
I know there are some convenient features within custom postgres images, but how often do you plan to migrate to a new major version? In my experience using a custom image will most likely lead to more work than it saves.
#dump
#import
The latest image: sameersbn/postgresql:latest is now pg14.8 and stops the warnings on gitlab startup
Note: Here are some special features of
sameersbn/postgresql:DB_EXTENSIONCREATE EXTENSION IF NOT EXISTS ..;). This can be transplant todocker-gitlabside, I think.btree_gitsis added by MR gitlab-org/gitlab!33340, especially gitlab-org/gitlab@b1dfb4a9. So we may not need to do anything about this.Sorry for being slow. Actually I wanted to have a look at the special features of the
sameersbn/postgresqlimage this week. Unfortunately, I was very busy this week, so I did not get around to it.However, I guess it makes more sense to use an official postgres image and thus, the documentation needs to be updated.
Not saying it’s right but was already using sameersbn/postgresql:latest in docker-compose, so I just did
docker-compose pulland then rebuild the containers.The logs show PG detecting the change, and auto updating:
Gitlab is then working fine for us, no data loss, and the admin page is reporting the correct version:
Good to know @davidglassborow and @sachilles, as the README.md and sample docker-compose.yml (https://github.com/sameersbn/docker-gitlab/blob/master/docker-compose.yml) are still mentioning
image: sameersbn/postgresql:12-20200524So we can “simply” replace
sameersbn/postgresql:12-20200524bysameersbn/postgresql:latest, or is still in testing ? Sticking to 15.11.x in the mean time.Since major versions of PostgreSQL might be related to breaking changes I’d strongly suggest to migrate from major version to major version, i.e. 12 then 13 then 14 then 15.
Hello everyone, I was wondering that can I use use sameersbn/postgres:14-20230628 for my gitlab? since it released but not updated in gitlab-docker-compose file!
Yeah I had to dump the old db, import it into the new version and then start everything and execute the db:migrate rake task manually. No idea why it skipped over one of the migrations but it lead to error 500 on load. Afterwards all seems fine. Maybe that’s just an issue with my installation.
Before merging this PR https://github.com/sameersbn/docker-postgresql/pull/158, you can use this zuojiazi/postgresql image instead of sameersbn/postgresql