6
4

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.

DockerでGitLabを構築

Last updated at Posted at 2018-11-10

環境

OS - software version
Mac Mojave 10.14
Docker 18.06.1-ce
docker-compose 1.22.0
GitLab Community Edition 11.4.0

docker-compose.ymlの取得

GitHubにGitLabのコンテナを起動できるdocker-compose.ymlがあるので取得。

$ mydir=myGitlab; cd && mkdir -p ${mydir} && cd ${mydir}
$ wget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml

docker-compose up -d で起動

docker-compose.ymlと同じディレクトリで実行。

$ docker-compose up -d

Creating network "docker-gitlab_default" with the default driver
Pulling redis (sameersbn/redis:4.0.9-1)...
4.0.9-1: Pulling from sameersbn/redis
6b98dfc16071: Pull complete
:
:
:
Status: Downloaded newer image for sameersbn/gitlab:11.4.0
Creating docker-gitlab_redis_1      ... error
Creating docker-gitlab_postgresql_1 ...

ERROR: for docker-gitlab_redis_1  Cannot start service redis: b'Mounts denied: \r\nThe path /srv/docker/gitlab/redis\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared pathCreating docker-gitlab_postgresql_1 ... error

ERROR: for docker-gitlab_postgresql_1  Cannot start service postgresql: b'Mounts denied: \r\nThe path /srv/docker/gitlab/postgresql\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.\r\n.'

ERROR: for redis  Cannot start service redis: b'Mounts denied: \r\nThe path /srv/docker/gitlab/redis\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.\r\n.'

ERROR: for postgresql  Cannot start service postgresql: b'Mounts denied: \r\nThe path /srv/docker/gitlab/postgresql\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.\r\n.'
ERROR: Encountered errors while bringing up the project.

エラーが発生。

  • 原因:docker-compose.ymlに記載されているvolumesオプションのパスが共有できない領域を指している為。
  • 解決方法:volumesオプションのホスト側のパスを共有できる領域に変更する。

エラー解消


$ # 差分確認用でバックアップ作成
$ cp docker-compose.yml docker-compose.yml.org

$ # sedで置換
$ sed -i -e 's/\/srv\/docker\/gitlab/\.\/srv\/docker\/gitlab/g' docker-compose.yml

$ # 差分確認
$ diff docker-compose.yml docker-compose.yml.org

--- docker-compose.yml	2018-10-29 17:14:00.000000000 +0900
+++ docker-compose.yml.org	2018-10-29 17:09:00.000000000 +0900
@@ -9,3 +9,3 @@
     volumes:
-    - ./srv/docker/gitlab/redis:/var/lib/redis:Z
+    - /srv/docker/gitlab/redis:/var/lib/redis:Z

@@ -15,3 +15,3 @@
     volumes:
-    - ./srv/docker/gitlab/postgresql:/var/lib/postgresql:Z
+    - /srv/docker/gitlab/postgresql:/var/lib/postgresql:Z
     environment:
@@ -32,3 +32,3 @@
     volumes:
-    - ./srv/docker/gitlab/gitlab:/home/git/data:Z
+    - /srv/docker/gitlab/gitlab:/home/git/data:Z
     environment:

/srv./srv になっていればOK。

再度 docker-compose up -d を実行

$ docker-compose up -d

Creating network "mygitlab_default" with the default driver
Creating mygitlab_redis_1      ... done
Creating mygitlab_postgresql_1 ... done
Creating mygitlab_gitlab_1     ... done

全てdoneになれば、OK。

GitLabのrootユーザーパスワード変更

    1. ブラウザでhttp://localhost:10080にアクセス。
    1. rootユーザーのパスワードを変更する画面が出てくるので、変更。

rootユーザー(管理者)でログイン

  • Username or emailの入力欄 : root
  • Passwordの入力欄 : 変更したパスワード

Welcome to GitLab の画面が出てくればOK。

6
4
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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?