QNAP NASの「Container Station」には、Docker Compose形式のYAMLファイルを使ってアプリケーションとしてコンテナ群を構築できる機能があります。この記事では、GitLabをYAMLファイルを使ってアプリケーションとして構築する方法を解説します。
✅ 事前準備
項目 | 内容 |
---|---|
NAS本体 | QNAP(x86 CPU搭載) |
OS | QTS 5.x (QuTS heroでもできると思う) |
アプリ | Container Station |
ネットワーク | NASのローカルIPを固定に設定推奨 |
📁 ステップ1:永続ボリュームのフォルダを作成
まず、GitLabの設定やデータを保存する場所を作っておきます。
QNAPの「File Station」で以下のパスを作成:
/share/Container/gitlab/
└ config
└ logs
└ data
🧾 ステップ2:docker-compose.ymlファイルを作成
任意のテキストエディタ(例:VS Code、メモ帳)で以下の内容を保存し、ファイル名を docker-compose.yml
にします。
version: '3'
services:
gitlab:
image: gitlab/gitlab-ce:latest
container_name: gitlab
restart: always
hostname: 'gitlab.local'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.32.253:10180'
gitlab_rails['gitlab_shell_ssh_port'] = 10122
nginx['listen_port'] = 80
ports:
- '10180:80'
- '10122:22'
volumes:
- /share/Container/gitlab/config:/etc/gitlab
- /share/Container/gitlab/logs:/var/log/gitlab
- /share/Container/gitlab/data:/var/opt/gitlab
☝
external_url
のIPアドレス(192.168.32.253
)は NASの実際のローカルIP に置き換えてください。
📦 ステップ3:Container Stationでアプリケーションを作成
- QNAPの「Container Station」を開く
- メニューの「アプリケーションを作成」をクリック
- yamlコード「アップロード」 → 「ローカルコンピューター」を選択
- アプリケーション名を設定(例:
gitlab-app
)
※3のアップロードの後、アプリケーション名がアップロードしたファイル名に変わるのでその後設定すること - ステップ2で作成した
docker-compose.yml
を選んでアップロード - 「作成」をクリック。バックグランドタスクでアプリケーションが作成中となる
- 作成完了後、状態が作成済となり、画面にアプリケーションとして表示される
🚀 ステップ4:アプリケーションの起動
- 作成されたGitLabアプリケーションを選択し、「起動」をクリック
- 数分でGitLabが起動します
- ブラウザでアクセス:
http://192.168.32.253:10180
🔐 初回ログイン
GitLabの初回アクセス時には、rootユーザーでログインします。
初期パスワードはSSHでログインし「initial_root_password 」の中身を確認します。
$ sudo cat /share/Container/gitlab/config/initial_root_password
Password:
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: XXXXXX/YYYYYYYYYY/ZZZZZZZZZZZZZZ=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
ブラウザで、ユーザー名root、パスワードは調べたパスワードを入力すると、ログインできるようになります。
パスワードは変更しておきましょう。
🎯 まとめ
QNAPのContainer Stationに備わっている「アプリケーション」機能を使えば、Docker Compose形式のYAMLファイルを簡単に構築可能です。
GitLabをローカルに置くことで、プライバシーの確保・ネットワーク負荷の軽減が可能になります。
コメント