Container registry metadata database: migration on docker installation

I am currently running Gitlab enterprise edition with all-in-one docker image, (gitlab/gitlab-ee) and enabled Container Registry before the availability of container registry metadata database.

With this image, a postgresql instance is run inside the container.

I am now having trouble migrating to the container registry metadata database. As Container registry metadata database | GitLab mentioned, I need to append something to gitlab.rb (despite I am currently passing configurations by GITLAB_OMNIBUS_CONFIG envvar, it is ok to use gitlab.rb) like below:

registry['database'] = {
  'enabled' => false, # Must be false!
  'host' => 'localhost',
  'port' => 5432,
  'user' => 'registry-database-user',
  'password' => 'registry-database-password',
  'dbname' => 'registry-database-name'
  'sslmode' => 'require', # See the PostgreSQL documentation for additional information https://www.postgresql.org/docs/current/libpq-ssl.html.
  'sslcert' => '/path/to/cert.pem',
  'sslkey' => '/path/to/private.key',
  'sslrootcert' => '/path/to/ca.pem'
}

But since I was on the all-in-one docker installation, I have no idea about the database name, db username or password to be filled in.

Any idea about this scenario?
Thanks.

+1 on this topic.

Have you found the solution?

I would have a look to:

then in addition
/var/opt/gitlab/postgresql/data/postgresql.conf
/var/opt/gitlab/postgresql/data/server.key
/var/opt/gitlab/postgresql/data/server.crt
/opt/gitlab/embedded/ssl/certs/cacert.pem

#ident_file = ‘ConfigDir/pg_ident.conf’ # ident configuration file
# (change requires restart)

also default user may be gitlab-psql:gitlab-psql

But it has been said on tickets that the registry requires a separate database. That could be another Postgres instance or a logical database inside the GitLab main database and i wonder what would happen with updates if you create a logical database against the internal Omnibus Pgsql server

I also struggle to get it working in docker installation

I was able to make it work by combining the official documentation with the snippet linked above:

Before running schema migrations, we need to create the database and user for the metadata database.
This can be done by running the following commands:

gitlab-psql -c "CREATE USER registry WITH PASSWORD 'registrypassword'"
gitlab-psql -c "CREATE DATABASE registry_database WITH OWNER registry"

Now use the created user and database in /etc/gitlab/gitlab.rb:
host is a path, since postgres runs in the same container and so the connection can use a unix socket.

registry['database'] = {
  'enabled' => false, # Must be false!
  'host' => '/var/opt/gitlab/postgresql/',
  'user' => 'registry',
  'password' => 'registrypassword',
  'dbname' => 'registry_database',
  'sslmode' => 'disable'
}

To allow the new user to connect to the database, we also need to add the following to /etc/gitlab/gitlab.rb:

postgresql['custom_pg_hba_entries'] = {
  registry_db: [
    {
      type: 'local',
      database: 'registry_database',
      user: 'registry',
      method: 'md5'
  }
  ]
}

After changing /etc/gitlab/gitlab.rb always run gitlab-ctl reconfigure to apply the changes.

We can now run the schema migrations, import the registry database and finally enable the metadata database.

Thank you so much! I spent half day trying to troubleshoot this and even opened another thread before stumbling on this. I can’t believe the migration documentation lacks these fundamental preliminary steps. Maybe I overlooked something?