How to run gitlab locally using docker-compose on mac os?

*How can I run gitlab locally using docker-compose on macOS?

I have tried different flavours of the docker-compose provided by git lab:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.example.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.example.com'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '80:80'
    - '443:443'
    - '22:22'
  volumes:
    - './.git/gitlab/config:/etc/gitlab'
    - './.git/gitlab/logs:/var/log/gitlab'
    - './.git/gitlab/data:/var/opt/gitlab'

When I say different flavours is that I tried both with ee and ce editions as well as different versions. latest and 13.6.5

However it is always failing due to the following error message:

web_1  | Running handlers:
web_1  | There was an error running gitlab-ctl reconfigure:
web_1  | 
web_1  | bash[migrate gitlab-rails database] (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
web_1  | ---- Begin output of "bash"  "/tmp/chef-script20210114-36-w3p5hn" ----
web_1  | STDOUT: rake aborted!
web_1  | PG::ConnectionBad: could not connect to server: No such file or directory
web_1  |        Is the server running locally and accepting
web_1  |        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
web_1  | /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:58:in `block (3 levels) in <top (required)>'
web_1  | /opt/gitlab/embedded/bin/bundle:23:in `load'
web_1  | /opt/gitlab/embedded/bin/bundle:23:in `<main>'
web_1  | Tasks: TOP => gitlab:db:configure
web_1  | (See full trace by running task with --trace)
web_1  | STDERR: 
web_1  | ---- End output of "bash"  "/tmp/chef-script20210114-36-w3p5hn" ----
web_1  | Ran "bash"  "/tmp/chef-script20210114-36-w3p5hn" returned 1
web_1  | 

From what I read from the documentation, the postgres is already bundled and no configuration is needed. However it seems it can not connect to Postgres :confused:

Some context:
I’m building a piece of software that will interact with gitlab rest API. And I want to have a running gitlab on my machine in order to run tests against it. The sw will make get requests to projects, commits, pipelines, jobs, etc. So for testing I need a gitlab where I can automatically create this resources in order to test my sw.

Thank you.

So, with a simple run I can start gitlab:

version: '3'
services:
  gitlab:
    image: gitlab/gitlab-ce:13.6.5-ce.0
    ports:
      - 8929:80

I still don’t know why the previous example is not working. It was Taken from here

I guess the problem are in the volumes?

Hi @gorogoro,

The issue you’re having is a problem with the location of your docker volumes.

From: GitLab Docker images | GitLab

Before setting everything else, configure a new environment variable $GITLAB_HOME pointing to the directory where the configuration, logs, and data files will reside.

For macOS users, use the user’s $HOME/gitlab directory:

export GITLAB_HOME=$HOME/gitlab

Then define the volumes using the $GITLAB_HOME variable in your docker-compose.yml, as seen in the example here

  volumes:
    - '$GITLAB_HOME/config:/etc/gitlab'
    - '$GITLAB_HOME/logs:/var/log/gitlab'
    - '$GITLAB_HOME/data:/var/opt/gitlab'

Hi,

Thank you for your reply. That did the trick. I was trying to mount the volumes on a different location, for some reason it did not worked.