1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gitlab ce をdockerコンテナでMac上に構築してみる

Last updated at Posted at 2020-03-13

gitlab ceをダウンロードして構築する。

自分のmacを無職になったのを機に開発用として、OSをクリーンインストールしたので、いろいろ遊んでみる。
最新版のGitlabをMac上に、dockerコンテナで構築して、自分のコードとかを保管しておく環境を作ってみる。

まず、情報収集から、検索ワード的には、「gitlab docker mac 構築」とかで検索しました。

  • Dockerのimageは、docker hubにありそう。
  • EEは、エンタープライズエディションらしいので、有償です。
  • CEは、コミニュティエディションらしいので、無料で使えます。
    検索ワード: gitlab ee ce 違い
dev@devPC ~ % sudo docker pull gitlab/gitlab-ce:latest
latest: Pulling from gitlab/gitlab-ce
fe703b657a32: Pull complete 
f9df1fafd224: Pull complete 
a645a4b887f9: Pull complete 
57db7fe0b522: Pull complete 
51f2452df587: Pull complete 
ca20bb0d0d35: Pull complete 
03b677c603dc: Pull complete 
a5cc90bd1eae: Pull complete 
fb67a436809a: Pull complete 
1295d3cf7f16: Pull complete 
Digest: sha256:fb97fba1e925dce93750bea9d51695c369250a99534793775c2c4fcb0a83bc3b
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest
dev@devPC ~ % 

docker imageのダウンロードをしてみた。起動コマンドはこんな感じです。

dev@devPC ~ % sudo docker run \                      
--hostname gitlab.example.com \
--publish 443:443 --publish 10080:80 --publish 22:22 \
--name gitlab_kun \
--restart always \
--volume /Users/dev/gitlab:/etc/gitlab \
--volume /Users/dev/gitlab:/var/log/gitlab \
--volume /Users/dev/gitlab:/var/opt/gitlab \
gitlab/gitlab-ce:latest

このコマンドをうって、PCからlocalhost:10080にアクセスすると、接続することができました。

  • オプションの説明です。

  • --publish (いつも -p って書いてるから、portの略かとおもったら、publishだったのか・・・・)

    • ホスト側のポート:コンテナ側のポート
    • 例えば、上のコマンドだとホストの10080にアクセスすると、コンテナの80ポートにアクセスすると言う意味です。そのため、gitlabのwebにアクセスすることができます。
  • --volumeについては、ホストとコンテナのデータをバインドするための設定です。

    • コンテナの中のデータは、コンテナが消えたときに一緒に破棄されてしまうので、バインドしておくことでホスト側にデータを保存しておくことができます。

gitlab-ctlコマンドで、いろいろできます。
設定を変えて変更したければ、gitlab-ctl reconfigure
ステータスをログをみたい場合には、gitlab-ctl status

root@gitlab:/# gitlab-ctl status
run: alertmanager: (pid 1489) 827s; run: log: (pid 610) 1228s
run: gitaly: (pid 251) 1296s; run: log: (pid 278) 1294s
run: gitlab-exporter: (pid 546) 1247s; run: log: (pid 548) 1246s
run: gitlab-workhorse: (pid 1461) 828s; run: log: (pid 513) 1264s
run: grafana: (pid 1511) 826s; run: log: (pid 1328) 886s
run: logrotate: (pid 533) 1253s; run: log: (pid 539) 1252s
run: nginx: (pid 523) 1260s; run: log: (pid 529) 1258s
run: postgres-exporter: (pid 1502) 826s; run: log: (pid 625) 1222s
run: postgresql: (pid 288) 1289s; run: log: (pid 373) 1287s
run: prometheus: (pid 1477) 827s; run: log: (pid 587) 1234s
run: redis: (pid 238) 1298s; run: log: (pid 248) 1297s
run: redis-exporter: (pid 1469) 828s; run: log: (pid 564) 1240s
run: sidekiq: (pid 491) 1272s; run: log: (pid 497) 1270s
run: sshd: (pid 22) 1318s; run: log: (pid 21) 1318s
run: unicorn: (pid 468) 1278s; run: log: (pid 485) 1276s
root@gitlab:/# 
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?