1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

おうちサーバー構築報告:GitLab in a Docker container →失敗

Posted at

能書き

おうちサーバー構築報告:予告からのおうちサーバー構築です。

以前もGitLabをインストールしましたが、今回は Proxmox VE のゲストマシンにDockerでインストールする事にしました。その手順となります。結局は上手くいかなかったんですが… ネットを探しても似た事例が無いんですよね。皆さん成功されているようで。Proxmox VE でやったのがダメだったんですかねぇ。原因不明です。とりあえず失敗の報告です。

なお、例のIntelCPU不安定問題の関連で、今はウチでは必要な時だけマシンを起動する運用に変えています。そのため証明書は定期的な自動更新が必要な Let's Encrypt ではなく、オレオレ認証局が認証した証明書を使う事にしました。

前提

目標

  • DockerでGitLabサーバー(17.10.4-ee.0)を立てる
  • リバースプロキシを利用し、オレオレ認証局が認証した証明書でhttpsアクセスできるようにする

GitLabをhttpsアクセスするのになぜリバースプロキシを経由するのかと言えば、私はグローバルIPアドレスを1つ持っているからです。色んなWebサーバを立てて運用しようとすると、その1つのIPアドレスを皆で共有する事になります。その為のリバースプロキシです。今はまだGitLabが1つだけですけども。

参考文献

今回の設定に必要な事前準備などは下記になります。

今まで2度ほどGitLabサーバーを立てました。その過去記事は下記になります。

GitLabをDockerコンテナにインストールする手順は公式に記載があります。英語なので自動翻訳してどうぞ。

docker hub でのGitLabのバージョンは下記で一覧表示できます。今の最新版は 17.10.4-ee.0 のようです。

今まで必要が無くて書いていませんでしたが、今回、rootユーザー以外でDockerを使う為のユーザーグループを設定します。

その他、エラーへの対応など。

GitLab

DockerコンテナにGitLabをインストールする

公式記事の通りの手順です。

ユーザー確認

ユーザーはデフォルトのadministratorとします。必要に応じて変更して下さい。

$ whoami
administrator

IPアドレス、ドメイン、ポート番号、ディレクトリ

我が家でDockerを入れている仮想マシンのIPアドレスは172.16.1.104です

そしてGitLabの為に最初に決めるのはドメイン名とポート番号ですな。

ドメイン名の方は仮にgitlab.example.comにしておきます。皆さんの環境に合わせて変えて下さい。ポート番号は80(及び10080)を避けるようにします。10080ポートを避ける理由はぐぐって下さい。

GITLAB_IPADDR=172.16.1.104
GITLAB_DOMAIN=gitlab.example.com
GITLAB_PORT=20080

それと、GitLabが使うSSHポート番号を決めます。

GITLAB_SSH_PORT=20022

それからGitLabサービス用のディレクトリを決めます。

export GITLAB_HOME=/srv/gitlab

ボリューム用のディレクトリを作成する

下記コマンドを実行します。

sudo mkdir -p $GITLAB_HOME
sudo chown -R $USER:$USER $GITLAB_HOME

Docker Composeを使用してGitLabをインストールする

docker hub の一覧表で最新の安定板を確認します。

GITLAB_VERSION=17.11.0

compose.yamlが、最近のdocker推奨ファイル名らしいです。

cat <<___ >$GITLAB_HOME/compose.yaml
services:
  gitlab:
    image: gitlab/gitlab-ee:$GITLAB_VERSION-ee.0
    container_name: gitlab
    restart: unless-stopped
    hostname: '$GITLAB_DOMAIN'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://$GITLAB_DOMAIN:$GITLAB_PORT'
        gitlab_rails['gitlab_shell_ssh_port'] = $GITLAB_SSH_PORT
    ports:
      - '$GITLAB_PORT:$GITLAB_PORT'
      - '$GITLAB_SSH_PORT:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    shm_size: '256m'
___

Docker 起動

さて起動です!

cd $GITLAB_HOME
docker compose up -d

起動プロセスを確認して、落ち着くまで待ちます。

docker compose logs -f

非常に時間が掛かりますな。掛かり過ぎです。30分を経過しても似たようなメッセージが繰り返し表示されていますので、諦めました。

何が悪かったのでしょう。Proxmox VE の仮想マシン内でdockerを使ったのが悪かったんでしょうか…

gitlab  |
gitlab  | ==> /var/log/gitlab/gitlab-exporter/current <==
gitlab  | 2025-04-19_12:23:50.09044 ::1 - - [19/Apr/2025:12:23:50 UTC] "GET /database HTTP/1.1" 200 1778
gitlab  | 2025-04-19_12:23:50.09047 - -> /database
gitlab  | 2025-04-19_12:23:57.28334 ::1 - - [19/Apr/2025:12:23:57 UTC] "GET /ruby HTTP/1.1" 200 1094
gitlab  | 2025-04-19_12:23:57.28335 - -> /ruby
gitlab  | 2025-04-19_12:23:59.17534 ::1 - - [19/Apr/2025:12:23:59 UTC] "GET /sidekiq HTTP/1.1" 200 508
gitlab  | 2025-04-19_12:23:59.17536 - -> /sidekiq
gitlab  |
gitlab  | ==> /var/log/gitlab/gitlab-rails/production_json.log <==
gitlab  | {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"time":"2025-04-19T12:24:02.218Z","params":[],"redis_calls":7,"redis_duration_s":0.000627,"redis_read_bytes":1192,"redis_write_bytes":390,"redis_feature_flag_calls":7,"redis_feature_flag_duration_s":0.000627,"redis_feature_flag_read_bytes":1192,"redis_feature_flag_write_bytes":390,"db_count":0,"db_write_count":0,"db_cached_count":0,"db_txn_count":0,"db_replica_txn_count":0,"db_primary_txn_count":0,"db_replica_count":0,"db_primary_count":0,"db_replica_write_count":0,"db_primary_write_count":0,"db_replica_cached_count":0,"db_primary_cached_count":0,"db_replica_wal_count":0,"db_primary_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_wal_cached_count":0,"db_replica_txn_max_duration_s":0.0,"db_primary_txn_max_duration_s":0.0,"db_replica_txn_duration_s":0.0,"db_primary_txn_duration_s":0.0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.0,"db_main_txn_count":0,"db_ci_txn_count":0,"db_main_replica_txn_count":0,"db_ci_replica_txn_count":0,"db_main_count":0,"db_ci_count":0,"db_main_replica_count":0,"db_ci_replica_count":0,"db_main_write_count":0,"db_ci_write_count":0,"db_main_replica_write_count":0,"db_ci_replica_write_count":0,"db_main_cached_count":0,"db_ci_cached_count":0,"db_main_replica_cached_count":0,"db_ci_replica_cached_count":0,"db_main_wal_count":0,"db_ci_wal_count":0,"db_main_replica_wal_count":0,"db_ci_replica_wal_count":0,"db_main_wal_cached_count":0,"db_ci_wal_cached_count":0,"db_main_replica_wal_cached_count":0,"db_ci_replica_wal_cached_count":0,"db_main_txn_max_duration_s":0.0,"db_ci_txn_max_duration_s":0.0,"db_main_replica_txn_max_duration_s":0.0,"db_ci_replica_txn_max_duration_s":0.0,"db_main_txn_duration_s":0.0,"db_ci_txn_duration_s":0.0,"db_main_replica_txn_duration_s":0.0,"db_ci_replica_txn_duration_s":0.0,"db_main_duration_s":0.0,"db_ci_duration_s":0.0,"db_main_replica_duration_s":0.0,"db_ci_replica_duration_s":0.0,"cpu_s":0.017606,"mem_objects":3851,"mem_bytes":2217304,"mem_mallocs":994,"mem_total_bytes":2371344,"pid":1043,"worker_id":"puma_0","rate_limiting_gates":[],"correlation_id":"a78c9b30-a837-4a0a-a25b-459f8f1b071d","db_duration_s":0.0,"view_duration_s":0.00033,"duration_s":0.01282}
以下省略

仕舞い

というわけで、GitLabをDockerで動かす目論見は失敗しました。同様の現象はネットをサーフィンしても出てこなかったです。もし原因に心当たりのある方がいらしたら、コメントで御指摘いただけると大変嬉しいです。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?