Docker for MacでGitLabを使ってみた|Blog|株式会社トライム
Docker for MacでGitLabを使ってみた
2017.04.11

Dockerをインストール
ダウンロードとインストールは、こちら Getting Started から。
インストーラー版もあります。Install Docker for Mac
現在のバージョン (2017年4月時点)
$ docker --version Docker version 17.03.0-ce, build 60ccb22 $ docker-compose --version docker-compose version 1.11.2, build dfed245 $ docker-machine --version docker-machine version 0.10.0, build 76ed2a6
Hello World
無事インストールされたか確認します。
$ docker run hello-world
下記のように出力されれば成功です。
Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
GitLabをインストール
docker-compose.ymlをダウンロード
GitLab用のDocker Composeのymlファイルをダウンロードします。
wgetコマンドを使いますので、インストールがまだの場合は下記ページが参考になります。
『Mac OS X – wgetコマンドをインストール(使えるようにする)』
$ wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml
このymlファイルに必要な環境設定がすべて書かれているので構築は簡単です。
そして、おもむろに下記コマンドを打ちます。
$ docker-compose up
が、怒られてしまいました。
ERROR: for postgresql Cannot start service postgresql: Mounts denied: . OR The path /srv/docker/gitlab/postgresql is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info. ERROR: for redis Cannot start service redis: Mounts denied: The path /srv/docker/gitlab/redis is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
docker-compose.ymlを編集
こちらのページを参考にさせていただき解決しました。
『Docker ComposeでGitLabをたてる for Mac』
docker-compose.ymlを編集します。
/Users/(ユーザー名)/docker-compose.yml
下記は参考ページから引用です。
services: redis: restart: always image: sameersbn/redis:latest command: - --loglevel warning volumes: # - /srv/docker/gitlab/redis:/var/lib/redis:Z ←ここを↓に変える - /Users/(ユーザー名)/docker/gitlab/redis:/var/lib/redis:Z postgresql: restart: always image: sameersbn/postgresql:9.6-2 volumes: # - /srv/docker/gitlab/postgresql:/var/lib/postgresql:Z ←ここを↓に変える - /Users/(ユーザー名)/docker/gitlab/postgresql:/var/lib/postgresql:Z environment: - DB_USER=gitlab - DB_PASS=password - DB_NAME=gitlabhq_production - DB_EXTENSION=pg_trgm gitlab: restart: always image: sameersbn/gitlab:8.16.5 depends_on: - redis - postgresql ports: - "10080:80" - "10022:22" volumes: # - /srv/docker/gitlab/gitlab:/home/git/data:Z ←ここを↓に変える - /Users/(ユーザー名)/docker/gitlab/gitlab:/home/git/data:Z environment: - DEBUG=false (省略)
上記、編集が終わったら改めて
$ docker-compose up
以上で、GitLabが使えるようになりました!
いざ、localhost:10080 へ。
来ました!
Contact
お問い合わせ
トライムは常にお客様へ寄りっ沿った提案をさせていただきます。
自社のEC売上の拡大や人材不足などのお客様のデジタル上の課題を、
様々なアプローチにより解決するお手伝いをいたします!
お気軽にお問い合わせください。
03-6403-3259
受付:10:00 - 19:00
