> ## Content Index
> Fetch the complete content index at: https://huizhou92.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How To Set Up GitLab On MacBook
- URL: https://huizhou92.com/how-to-set-up-gitlab-on-macbook/
- Published: 2024-11-16T08:03:06.000Z
- Updated: 2026-09-08T02:30:04.000Z
- Description: How To Set Up GitLab On MacBook. Recently, I wanted to learn about infrastructure knowledge systematically, so I planned to build a learning environment. S。
- Author: huizhou92
- Tags: #Migrated-1788833207488, #Import 2026-09-08 02:07

Recently, I wanted to learn about infrastructure knowledge systematically, so I planned to build a learning environment. Since I don’t have any extra machines, I used Docker on my `MacBookPro M1` to build an environment. At present, it seems that the first step is going smoothly.

### Installing GitLab

The M1 chip in MacBooks uses the ARM architecture, so I used the `yrzr/gitlab-ce-arm64v8:latest` Docker image.

#### Create Required Directories

First, create three working directories for GitLab: `etc`, `log`, and `opt`. Otherwise, errors will occur. Modify the `volumes` section in the Docker Compose configuration to point to these directories. Two ports, `9922` and `9980`, are exposed. Since this setup is for local use, `443` it is not enabled.

```yaml
# dockerfile  
version: "3.8" 
services: 
  gitlab-ce: 
    image: yrzr/gitlab-ce-arm64v8:latest 
    container_name: gitlab-ce 
    privileged: true 
    restart: always 
    ports: 
      - "9922:22" 
      - "9980:9980" 
    volumes: 
      - /Users/hxzhouh/tools/gitlab/etc:/etc/gitlab:z 
      - /Users/hxzhouh/tools/gitlab/log:/var/log/gitlab:z 
      - /Users/hxzhouh/tools/gitlab/opt:/var/opt/gitlab:z 
    deploy: 
      resources: 
        limits: 
          memory: 4096M 
    tty: true 
    stdin_open: true
```

> **Note:** It’s important to note that we’re exposing port 9980 to the public because we’ll be configuring gitlab’s http port to run on 9980 later instead of the default 80, and we’re doing this to avoid this problem:

[https://stackoverflow.com/questions/66961517/gitlab-http-clone-url-is-wrong-port-8022-missing](https://stackoverflow.com/questions/66961517/gitlab-http-clone-url-is-wrong-port-8022-missing?ref=huizhou92.com)

#### Update GitLab Configuration

Once the container is running, modify the GitLab configuration file:

```shell
docker exec -it gitlab-ce /bin/bash 
vi /etc/gitlab/gitlab.rb
```

Add the following lines at the end:

```ruby
external_url 'http://127.0.0.1:9980' 
gitlab_rails['gitlab_ssh_host'] = '127.0.0.1' 
gitlab_rails['gitlab_shell_ssh_port'] = 9922
```

#### Change the Default Password

Run the following commands to update the root password:

```shell
gitlab-rails console -e production 
user = User.where(id: 1).first 
user.password = 'AIl+mVN(:bk\#5%c' 
user.save!
```

![](https://huizhou92.com/content/images/2026/09/1-iamaiwemhfsdvjonl3loxa.png)

Finally, reconfigure and restart GitLab:

```shell
gitlab-ctl reconfigure 
gitlab-ctl restart
```

![](https://huizhou92.com/content/images/2026/09/0-_ckt2zibemr-nbhs.png)

#### Access GitLab

Visit `http://127.0.0.1:9980` in your browser. The default `root` username and the password you just set should work.

#### Adding SSH

To enable SSH-based access like `GitHub`, create an SSH key pair and add the public key to GitLab, and update your local SSH configuration in `~/.ssh/config`:

```plaintext
Host 127.0.0.1 
HostName 127.0.0.1 
Port 9922 
IdentityFile ~/.ssh/ssh 
PreferredAuthentications publickey 
User root
```

Test the connection:

```shell
ssh -T git@127.0.0.1
```

You should see:

```plaintext
Welcome to GitLab, @root!
```

Then, Create a new project and clone,modify, push it

![](https://huizhou92.com/content/images/2026/09/0-4objonlnca7-p16k.png)

```shell
git clone ssh://git@127.0.0.1:9922/root/hello-world.git 
some modify  
..... 
git push origin --force
```

```shell
➜  hello-world git:(main) git push origin --force 
To ssh://127.0.0.1:9922/root/hello-world.git 
   b4dd724..e45f213  main -> main
```

Everything’s working fine.😄

### Configuring GitLab Runners

Go to **Settings** \-> **CI/CD** \-> **Runners**, and follow the instructions under “Show runner installation and registration instructions.”

![](https://huizhou92.com/content/images/2026/09/0-2tlbygwtruys7w9a.png)

#### Install and Register the Runner

```shell
sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64 
sudo chmod +x /usr/local/bin/gitlab-runner 
gitlab-runner install 
gitlab-runner start 
gitlab-runner register --url http://127.0.0.1:9980 --registration-token GR13489416KQ-jitR3JhfMgr8f-9G
```

![](https://huizhou92.com/content/images/2026/09/0-7pd7n-fymzsx6mot.png)

**Key Points:**

1. **Tags:** Use tags to specify runner tasks in `.gitlab-ci.yml`.
2. **Executor:** For this example, use the `shell` executor.

For more information about GitLab Runner, please refer to the article on the [official website](https://docs.gitlab.com/runner/?ref=huizhou92.com), which will not be expanded here.

#### Testing CI/CD Pipeline

Create a `.gitlab-ci.yml` file in your project:

```yaml
stages:   
  - build   
build_job:   
  stage: build   
  tags:   
    - golang-local-shell   
  script:   
    - go build -o myapp   
  only:   
    - main   
    - tags   
  artifacts:   
    paths:   
      - myapp
```

Push the code to GitLab, and the build pipeline should execute automatically.

![](https://huizhou92.com/content/images/2026/09/0-ennmljmzv0lr588a.png)

Artifacts can be found at:

```shell
http://127.0.0.1:9980/root/hello-world/-/artifacts
```

![](https://huizhou92.com/content/images/2026/09/0-jowyq7btdkz2ol7r.png)

### Next Steps

This setup concludes the local GitLab environment. In the next article, I’ll demonstrate setting up a local Kubernetes cluster and automating Docker image deployment from GitLab to Kubernetes for a complete CI/CD pipeline.