-- 前回 --
-- 今回 --
前回までで必要なイメージを取得しているので、podman-compose.ymlを作成して、コンテナの起動を試みる。
まず ymlファイルの配置先となる作業用ディレクトリを作成し、移動しておく。
[root@git-server gitlab]# pwd
/uwork/podman_project/gitlab
podman-compose.ymlを作成する。
前回取得したイメージをymlファイル内で指定している。
[root@git-server gitlab]# podman image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/gitlab/gitlab-runner alpine3.18-bleeding b266aee400ad 2 months ago 206 MB
docker.io/gitlab/gitlab-ce 18.0.4-ce.0 c4992655fb5f 2 months ago 3.71 GB
quay.io/podman/hello latest 5dd467fce50b 16 months ago 787 kB
[root@git-server gitlab]#
[root@git-server gitlab]# vi ./podman-compose.yml
version: '3.6'
services:
gitlab:
image: docker.io/gitlab/gitlab-ce:18.0.4-ce.0
container_name: gitlab
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.56.111'
HOME_DIR: /home/ec2-user
ports:
- '8080:80'
- '8443:443'
- '10022:22'
volumes:
- /home/ec2-user/gitlab-gitlabrunner/gitlab/config:/etc/gitlab
- /home/ec2-user/gitlab-gitlabrunner/gitlab/logs:/var/log/gitlab
- /home/ec2-user/gitlab-gitlabrunner/gitlab/data:/var/opt/gitlab
shm_size: '256m'
gitlab-runner:
image: docker.io/gitlab/gitlab-runner:alpine3.18-bleeding
container_name: gitlab-runner
restart: always
environment:
HOME_DIR: /home/ec2-user
volumes:
- /home/ec2-user/gitlab-gitlabrunner/gitlab-runner/config:/etc/gitlab-runner
- /home/ec2-user/.ssh:/root/.ssh
環境変数 GITLAB_OMNIBUS_CONFIG:gitlab.rb の設定内容を記載する
external_url:GitLabへアクセスするためのURL ※ Virtualbox ゲストOSのIPを指定
GitLabの設定等を永続化するために volumes で、コンテナ ー> Virtualbox上のゲストOSのディレクトリをマウント。
続いて各種ディレクトリが存在するか、コンテナ起動前に存在確認を行う。
※ 今回 root権限でコンテナを起動しているが、本来は適したユーザで、適したディレクトリを指定した方が良さそう
[root@git-server gitlab]# tree /home/ec2-user/2
/home/ec2-user
└── gitlab-gitlabrunner
├── gitlab
│ ├── config
│ ├── data
│ └── logs
└── gitlab-runner
└── config
作成したpodman-compose.yml を使って、コンテナを起動。
フォアグラウンドではなくバックグラウンドで動くように "-d" オプションをつけて実行する。
[root@git-server gitlab]# podman-compose -f podman-compose.yml up -d
ba3b3d342925da61ae4077394574cc149590cdff03934f908dc68cd2f1cc085f
1d8a31156aab4154dd483ccecb4b78ba1ebe7c71011a4a21121c2eafa8f60bb0
f3f097e5b5df909bf8823f4d2a1ceeefe61856478fa6bf29b87cb096392b3c03
gitlab
gitlab-runner
起動後のステータス確認。
時間をおいて何度か確認を繰り返す。
[root@git-server gitlab]# podman image lsps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
422d717db105 quay.io/podman/hello:latest /usr/local/bin/po... 2 months ago Exited (0) 2 months ago pedantic_chaplygin
1d8a31156aab docker.io/gitlab/gitlab-ce:18.0.4-ce.0 /assets/init-cont... 21 seconds ago Up 2 seconds (starting) 0.0.0.0:8080->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:10022->22/tcp gitlab
f3f097e5b5df docker.io/gitlab/gitlab-runner:alpine3.18-bleeding run --user=gitlab... 21 seconds ago Up 20 seconds gitlab-runner
~~ 中略 ~~
[root@git-server gitlab]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
422d717db105 quay.io/podman/hello:latest /usr/local/bin/po... 2 months ago Exited (0) 2 months ago pedantic_chaplygin
1d8a31156aab docker.io/gitlab/gitlab-ce:18.0.4-ce.0 /assets/init-cont... About a minute ago Up 3 seconds (starting) 0.0.0.0:8080->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:10022->22/tcp gitlab
f3f097e5b5df docker.io/gitlab/gitlab-runner:alpine3.18-bleeding run --user=gitlab... About a minute ago Up About a minute gitlab-runner
~~ 中略 ~~
[root@git-server gitlab]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
422d717db105 quay.io/podman/hello:latest /usr/local/bin/po... 2 months ago Exited (0) 2 months ago pedantic_chaplygin
1d8a31156aab docker.io/gitlab/gitlab-ce:18.0.4-ce.0 /assets/init-cont... 4 minutes ago Initialized (starting) 0.0.0.0:8080->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:10022->22/tcp gitlab
f3f097e5b5df docker.io/gitlab/gitlab-runner:alpine3.18-bleeding run --user=gitlab... 4 minutes ago Up 4 minutes gitlab-runner
~~ 中略 ~~
[root@git-server gitlab]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
422d717db105 quay.io/podman/hello:latest /usr/local/bin/po... 2 months ago Exited (0) 2 months ago pedantic_chaplygin
1d8a31156aab docker.io/gitlab/gitlab-ce:18.0.4-ce.0 /assets/init-cont... 6 minutes ago Exited (1) 2 seconds ago (starting) 0.0.0.0:8080->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:10022->22/tcp gitlab
f3f097e5b5df docker.io/gitlab/gitlab-runner:alpine3.18-bleeding run --user=gitlab... 6 minutes ago Up 6 minutes gitlab-runner
最終的にgitlab-ceは、起動せずに停止(Exited)してしまった。
原因調査のために、コンテナのログを確認する。
コンテナ起動時のトラブルシュート
(1)ログ確認
docker logs [コンテナ名]
原因特定できなれば、以降の手順を実施する
(2)コンテナのイメージ化
docker commit [コンテナID] [任意のイメージ名]
(3)コンテナへ接続
docker run --rm [任意のイメージ名] bash
※ --rm オプション:コンテナ実行後に削除してくれる
【 コンテナへの接続方法 】
docker exec -it [コンテナ名] bash
dokcer attach [コンテナ名]
gitlab-ce と gitlab-runner の両方のログを確認してみる。
[ gitlab-ce ]
[root@git-server gitlab]# podman logs 1d8a31156aab | head -100
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=18.0.4-ce.0
Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:
docker exec -it gitlab editor /etc/gitlab/gitlab.rb
docker restart gitlab
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
If this container fails to start due to permission problems try to fix it by executing:
docker exec -it gitlab update-permissions
docker restart gitlab
find: ‘/var/opt/gitlab’: Permission denied
Cleaning stale PIDs & sockets
cat: /var/opt/gitlab/gitlab-rails/VERSION: No such file or directory
Installing gitlab.rb config...
cp: cannot create regular file '/etc/gitlab/gitlab.rb': Permission denied
~~ 以降、同じメッセージが繰り返される ~~
[ gitlab-runner ]
[root@git-server gitlab]# podman logs f3f097e5b5df
Runtime platform arch=amd64 os=linux pid=2 revision=a17adc6a version=18.2.0~pre.109.ga17adc6a
Starting multi-runner from /etc/gitlab-runner/config.toml... builds=0 max_builds=0
Running in system-mode.
Created missing unique system ID system_id=r_3y0C7sQsgOeV
WARNING: Couldn't save new system ID on state file. In order to reliably identify this runner in jobs with a known identifier,
please ensure there is a text file at the location specified in `state_file` with the contents of `system_id`. Example: echo "r_3y0C7sQsgOeV" > "/etc/gitlab-runner/.runner_system_id"
state_file=/etc/gitlab-runner/.runner_system_id system_id=r_3y0C7sQsgOeV
Usage logger disabled builds=0 max_builds=1
Configuration loaded builds=0 max_builds=1
listen_address not defined, metrics & debug endpoints disabled builds=0 max_builds=1
[session_server].listen_address not defined, session endpoints disabled builds=0 max_builds=1
Initializing executor providers builds=0 max_builds=1
ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory builds=0 max_builds=1
ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory builds=0 max_builds=1
ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory builds=0 max_builds=1
~~ 以降、同じメッセージが繰り返される ~~
gitlab-ce と gitlab-runner ともに、volumes のマウントでエラーになっている。
調べてみると、SELinuxを無効化する必要があるようだ。
[root@git-server gitlab]# getenforce
Enforcing
[root@git-server gitlab]# vi /etc/selinux/config
#SELINUX=enforcing <--コメントアウト
SELINUX=disabled <--を追記
設定を反映するためにOS再起動
[root@git-server gitlab]# reboot
~ OS再起動後に確認 ~
[root@git-server ~]# getenforce
Disabled
SELinuxが無効化できたので、コンテナを起動。
[root@git-server gitlab]# pwd
/uwork/podman_project/gitlab
[root@git-server gitlab]# podman-compose -f podman-compose.yml up -d
gitlab
gitlab-runner
[root@git-server gitlab]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
422d717db105 quay.io/podman/hello:latest /usr/local/bin/po... 3 months ago Exited (0) 3 months ago pedantic_chaplygin
9d4d18a09f55 docker.io/gitlab/gitlab-ce:18.0.4-ce.0 /assets/init-cont... 5 days ago Up 5 minutes (healthy) 0.0.0.0:8080->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:10022->22/tcp gitlab
0309f185eb74 docker.io/gitlab/gitlab-runner:alpine3.18-bleeding run --user=gitlab... 5 days ago Up 5 minutes gitlab-runner
[root@git-server gitlab]#
起動できたので、Virtualbox上のゲストOS(コンテナからみるとホストOS)から、ブラウザで gitlab-ce へアクセス。
上記のとおり、ログイン画面の表示までこれた。
参考までに今回の環境構成を下記に残しておく。
-- 参考(先人達に感謝) --
podman-compose.ymlなど
トラブルシュート系
GitLabの日本語マニュアル
以上.