LoginSignup
1
5

More than 3 years have passed since last update.

MACでDocker(docker-compose)を使用してローカルで使用するgitlabを起動

Posted at

MAC上でdocker-composeを使用してローカルで使用するgitlabを起動(備忘)

環境

macOS 10.14.4
Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01 (docker同梱)

参照

Install GitLab using docker-compose (公式)

docker-compose.yml

another docker-compose.yml exampleを編集して使用

docker-compose.yml
---
version: '3'
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: localhost
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://localhost:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
      - '8929:8929'
      - '2224:22'
    volumes:
      - /Users/Shared/gitlab/config:/etc/gitlab
      - /Users/Shared/gitlab/logs:/var/log/gitlab
      - /Users/Shared/gitlab/data:/var/opt/gitlab

編集箇所

  • hostnameとexternal_urlをlocalhost(127.0.0.1)を使用する様に編集
  • volumes:における/srv/gitlabを、MAC環境に合わせて/Users/Sharedに編集

起動

$ ls
docker-compose.yml

$ docker-compose up -d 
Pulling web (gitlab/gitlab-ce:latest)...
latest: Pulling from gitlab/gitlab-ce
7e6591854262: Pull complete
089d60cb4e0a: Pull complete
9c461696bc09: Pull complete
45085432511a: Pull complete
fe923449954f: Pull complete
f7944584e435: Pull complete
47472ef1aa19: Pull complete
80d72d7c3c00: Pull complete
bb2031d6299d: Pull complete
7b6ae18e4081: Pull complete
Creating gitlab-docker_web_1 ... done

$ docker-compose ps
       Name               Command               State                                       Ports                            
-----------------------------------------------------------------------------------------------------------------------------
gitlab-docker_web_1   /assets/wrapper   Up (health: starting)   0.0.0.0:2224->22/tcp, 443/tcp, 80/tcp, 0.0.0.0:8929->8929/tcp

$ docker images gitlab/gitlab-ce:latest
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
gitlab/gitlab-ce    latest              17d5117a2e37        6 days ago          1.76GB

接続

http://localhost:8929 に接続すると、Gitlabのrootパスワード設定画面が表示される。設定し、改めてrootでloginする。
あとはユーザーを作成し、ssh公開キーを登録するなど普通に使用可能。
プロジェクトは ssh://git@localhost:2224/<ユーザー名>/<プロジェクト名>.git などとなる。

停止、除去

$ docker-compose stop 
Stopping gitlab-docker_web_1 ... done

$ docker-compose rm -f
Going to remove gitlab-docker_web_1
Removing gitlab-docker_web_1 ... done

なお、設定やプロジェクトなどは /Users/Shared/gitlab 下に残っているので、再び docker-compose up -d とすることで、再起動可。

$ docker-compose up -d 
Creating gitlab-docker_web_1 ... done

URLに接続できるまでは若干時間が掛かる。

設定変更

設定ファイルを使用する場合、/Users/Shared/gitlab/config/gitlab.rbを編集後、docker-compose stop; docker-compose up -d

アップデート

Update GitLab using Docker compose (公式)

$ docker-compose pull 
Pulling web ... done

$ docker-compose up -d 
Recreating gitlab-docker_web_1 ... done
1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5