Local GitLab DOCKER does not work on MacOS (Apple M2) - postgresql error

I am trying to run GitLab (EE or CE) on macOS using docker following this guide: https://docs.gitlab.com/ee/install/docker.html

Environment:

  • Chip: Apple M2 Pro
  • macOs: Sonoma 14.2.1 (23C71)
  • Docker: version 24.0.6, build ed223bc
  • GitLab: gitlab/gitlab-ee:16.7.0-ee.0 (latest)

Notes:

  • ~/gitlab folder is empty
  • I also added gitlab.local to my hosts.
export GITLAB_HOME=~/gitlab

docker run --detach \
  --hostname gitlab.local \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  --shm-size 256m \
  --platform linux/amd64 \
  gitlab/gitlab-ee:16.7.0-ee.0

Command failed with Error:

[2023-12-28T08:31:58+00:00] INFO: execute[/opt/gitlab/bin/gitlab-ctl start postgresql] ran successfully
    - execute /opt/gitlab/bin/gitlab-ctl start postgresql
  * database_objects[postgresql] action create
    * postgresql_user[gitlab] action create
      * execute[create gitlab postgresql user] action run
        
        ================================================================================
        Error executing action `run` on resource 'execute[create gitlab postgresql user]'
        ================================================================================
        
        RuntimeError
        ------------
        PostgreSQL did not respond before service checks were exhausted
Full error output:
[2023-12-28T08:31:58+00:00] INFO: execute[/opt/gitlab/bin/gitlab-ctl start postgresql] ran successfully
    - execute /opt/gitlab/bin/gitlab-ctl start postgresql
  * database_objects[postgresql] action create
    * postgresql_user[gitlab] action create
      * execute[create gitlab postgresql user] action run
        
        ================================================================================
        Error executing action `run` on resource 'execute[create gitlab postgresql user]'
        ================================================================================
        
        RuntimeError
        ------------
        PostgreSQL did not respond before service checks were exhausted
        
        Cookbook Trace: (most recent call first)
        ----------------------------------------
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helpers/pg_status_helper.rb:56:in `ready?'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helpers/base_pg_helper.rb:28:in `is_ready?'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:16:in `block (3 levels) in class_from_file'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:13:in `block in class_from_file'
        /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:28:in `block in class_from_file'
        
        Resource Declaration:
        ---------------------
        # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb
        
         13:   execute "create #{new_resource.username} postgresql user" do
         14:     command %(/opt/gitlab/bin/#{new_resource.helper.service_cmd} -d template1 -c "#{query}")
         15:     user account_helper.postgresql_user
         16:     only_if { new_resource.helper.is_running? && new_resource.helper.is_ready? }
         17:     not_if { new_resource.helper.is_offline_or_readonly? || new_resource.helper.user_exists?(new_resource.username) }
         18:   end
         19: 
        
        Compiled Resource:
        ------------------
        # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:13:in `block in class_from_file'
        
        execute("create gitlab postgresql user") do
          action [:run]
          default_guard_interpreter :execute
          command "/opt/gitlab/bin/gitlab-psql -d template1 -c \"CREATE USER \\\"gitlab\\\"\""
          declared_type :execute
          cookbook_name "postgresql"
          recipe_name "standalone"
          domain nil
          user "gitlab-psql"
          not_if { #code block }
          only_if { #code block }
        end
        
        System Info:
        ------------
        chef_version=17.10.0
        platform=ubuntu
        platform_version=22.04
        ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
        program_name=/opt/gitlab/embedded/bin/cinc-client
        executable=/opt/gitlab/embedded/bin/cinc-client
        
      
      ================================================================================
      Error executing action `create` on resource 'postgresql_user[gitlab]'
      ================================================================================
      
      RuntimeError
      ------------
      execute[create gitlab postgresql user] (postgresql::standalone line 13) had an error: RuntimeError: PostgreSQL did not respond before service checks were exhausted
      
      Cookbook Trace: (most recent call first)
      ----------------------------------------
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helpers/pg_status_helper.rb:56:in `ready?'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helpers/base_pg_helper.rb:28:in `is_ready?'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:16:in `block (3 levels) in class_from_file'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:13:in `block in class_from_file'
      /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:28:in `block in class_from_file'
      
      Resource Declaration:
      ---------------------
      # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb
      
       28:   postgresql_user gitlab_sql_user do
       29:     password "md5#{gitlab_sql_user_password}" unless gitlab_sql_user_password.nil?
       30:     action :create
       31:   end
       32: 
      
      Compiled Resource:
      ------------------
      # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:28:in `block in class_from_file'
      
      postgresql_user("gitlab") do
        action [:create]
        default_guard_interpreter :default
        declared_type :postgresql_user
        cookbook_name "postgresql"
        recipe_name "standalone"
        helper "*sensitive value suppressed*"
      end
      
      System Info:
      ------------
      chef_version=17.10.0
      platform=ubuntu
      platform_version=22.04
      ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
      program_name=/opt/gitlab/embedded/bin/cinc-client
      executable=/opt/gitlab/embedded/bin/cinc-client
      
    
    ================================================================================
    Error executing action `create` on resource 'database_objects[postgresql]'
    ================================================================================
    
    RuntimeError
    ------------
    postgresql_user[gitlab] (postgresql::standalone line 28) had an error: RuntimeError: execute[create gitlab postgresql user] (postgresql::standalone line 13) had an error: RuntimeError: PostgreSQL did not respond before service checks were exhausted
    
    Cookbook Trace: (most recent call first)
    ----------------------------------------
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helpers/pg_status_helper.rb:56:in `ready?'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/helpers/base_pg_helper.rb:28:in `is_ready?'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:16:in `block (3 levels) in class_from_file'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/resources/user.rb:13:in `block in class_from_file'
    /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/database_objects.rb:28:in `block in class_from_file'
    
    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/standalone.rb
    
     32: database_objects 'postgresql' do
     33:   pg_helper pg_helper
     34:   account_helper account_helper
     35:   not_if { pg_helper.replica? }
     36: end
     37: 
    
    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/postgresql/recipes/standalone.rb:32:in `from_file'
    
    database_objects("postgresql") do
      action [:create]
      default_guard_interpreter :default
      declared_type :database_objects
      cookbook_name "postgresql"
      recipe_name "standalone"
      pg_helper "*sensitive value suppressed*"
      account_helper "*sensitive value suppressed*"
      not_if { #code block }
    end
    
    System Info:
    ------------
    chef_version=17.10.0
    platform=ubuntu
    platform_version=22.04
    ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
    program_name=/opt/gitlab/embedded/bin/cinc-client
    executable=/opt/gitlab/embedded/bin/cinc-client
    
[2023-12-28T08:33:34+00:00] INFO: Running queued delayed notifications before re-raising exception
[2023-12-28T08:33:34+00:00] INFO: templatesymlink[Create a gitlab.yml and create a symlink to Rails root] sending run action to execute[clear the gitlab-rails cache] (delayed)
Recipe: gitlab::gitlab-rails
  * execute[clear the gitlab-rails cache] action run[2023-12-28T08:33:49+00:00] INFO: execute[clear the gitlab-rails cache] ran successfully

    - execute /opt/gitlab/bin/gitlab-rake cache:clear
[2023-12-28T08:33:49+00:00] INFO: version_file[Create version file for Gitaly] sending hup action to runit_service[gitaly] (delayed)
Recipe: gitaly::enable
  * runit_service[gitaly] action hup[2023-12-28T08:33:49+00:00] INFO: runit_service[gitaly] signalled (HUP)
[2023-12-28T08:33:49+00:00] INFO: runit_service[gitaly] sent hup

    - send hup to runit_service[gitaly]

Running handlers:
[2023-12-28T08:33:49+00:00] ERROR: Running exception handlers

There was an error running gitlab-ctl reconfigure:

database_objects[postgresql] (postgresql::standalone line 32) had an error: RuntimeError: postgresql_user[gitlab] (postgresql::standalone line 28) had an error: RuntimeError: execute[create gitlab postgresql user] (postgresql::standalone line 13) had an error: RuntimeError: PostgreSQL did not respond before service checks were exhausted

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Running handlers complete
[2023-12-28T08:33:49+00:00] ERROR: Exception handlers complete
Infra Phase failed. 245 resources updated in 02 minutes 43 seconds

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

[2023-12-28T08:33:49+00:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/cinc-stacktrace.out
[2023-12-28T08:33:49+00:00] FATAL: ---------------------------------------------------------------------------------------
[2023-12-28T08:33:49+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
[2023-12-28T08:33:49+00:00] FATAL: ---------------------------------------------------------------------------------------
[2023-12-28T08:33:49+00:00] FATAL: RuntimeError: database_objects[postgresql] (postgresql::standalone line 32) had an error: RuntimeError: postgresql_user[gitlab] (postgresql::standalone line 28) had an error: RuntimeError: execute[create gitlab postgresql user] (postgresql::standalone line 13) had an error: RuntimeError: PostgreSQL did not respond before service checks were exhausted

Any suggestions?