PostgreSQL upgrade fails from GitLab 9.0.4 to 9.0.5

I try to upgrade GitLab 9.0.4 to 9.0.5 by switching the Docker image to gitlab/gitlab-ce:9.0.5-ce.0 but it crashs when trying to upgrade Postgres. I saw nothing suspicious in /var/log/gitlab except query/connection failures due to the DB crash:

PG::ConnectionBad (could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
ActiveRecord::StatementInvalid (PG::UnableToSend: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

Container output:

Thank you for using GitLab Docker Image!
Current version: gitlab-ce=9.0.5-ce.0

Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

  docker exec -it gitlab vim /etc/gitlab/gitlab.rb
  docker restart gitlab

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

Preparing services...
Starting services...
Configuring GitLab package...
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
Configuring GitLab...


  * Moving existing certificates found in /opt/gitlab/embedded/ssl/certs

  * Symlinking existing certificates found in /etc/gitlab/trusted-certs
gitlab Reconfigured!
Checking for an omnibus managed postgresql: OK
Checking if we already upgraded: NOT OK
Checking for a newer version of PostgreSQL to install: OK
Upgrading PostgreSQL to 9.6.1
Checking if PostgreSQL bin files are symlinked to the expected location: OK
cp /opt/gitlab/embedded/service/gitlab-rails/public/deploy.html /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: down: gitaly: 0s, normally up
ok: down: gitlab-monitor: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 1s, normally up
ok: down: prometheus: 0s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 0s, normally up
Toggling services: OK
Stopping the database:ok: down: postgresql: 0s, normally up
Stopping the database: OK
Update the symlinks: OK
Creating temporary data directory: OK
Initializing the new database:Error initializing database for 9.6.1
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.

The database cluster will be initialized with locale "C.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

STDERR: initdb: directory "/var/opt/gitlab/postgresql/data.9.6.1" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/opt/gitlab/postgresql/data.9.6.1" or run initdb
with an argument other than "/var/opt/gitlab/postgresql/data.9.6.1".
== Fatal error ==
Please check the output and try again
== Reverting ==
ok: down: postgresql: 1s, normally up
ok: run: postgresql: (pid 874) 0s
== Reverted ==
== Reverted to 9.2.18. Please check output for what went wrong ==
rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: run: gitaly: (pid 885) 0s
ok: run: gitlab-monitor: (pid 887) 1s
ok: run: logrotate: (pid 894) 0s
ok: run: node-exporter: (pid 900) 0s
ok: run: postgres-exporter: (pid 902) 1s
ok: run: prometheus: (pid 914) 0s
ok: run: redis-exporter: (pid 916) 0s
ok: run: sidekiq: (pid 927) 1s
Toggling services: OK
Upgrading the existing database to 9.6 failed and was reverted.
Please check the output, and open an issue at:
https://gitlab.com/gitlab-org/omnibus-gitlab/issues
If you would like to restart the instance without attempting to
upgrade, add the following to your docker command:
-e GITLAB_SKIP_PG_UPGRADE=true