# Podmanによるインストール；

## はじめに

| 項目        | 最小要件                                                             | 補足                                  |
| --------- | ---------------------------------------------------------------- | ----------------------------------- |
| Linuxサーバー | RHEL 9 / Alma 9 / Rocky 9 / Fedora 39またはUbuntu 24.04 / Debian 12 | Podman 5以降が搭載されている最新のディストリビューションで機能 |
| パッケージ     | `podman`および`podman-compose`                                      | 手順3でインストール                          |
| ネットワーク    | 空きTCPポート1つ (例では8080を使用)                                          | HTTPSを使用する場合はポート80と443も開放が必要        |

## 1. 作業用フォルダの作成とComposeファイルの保存

サーバーにログインし、以下を実行します。

```bash
sudo mkdir -p /opt/kcm && cd /opt/kcm
```

ブラウザで[Docker Composeインストール](/keeper-connection-manager/jp/installation/docker-compose-install.md)のページ を開き、**\[Step 2 — Create Docker Compose File]** にスクロールします。YAMLブロックをコピーして、`/opt/kcm/docker-compose.yml`に貼り付けます。

***

## 2. セキュリティ強化されたseccompプロファイルのダウンロード

インストールスクリプトを使わない場合は、以下のように手動で取得します。

```bash
sudo mkdir -p /etc/kcm-setup
sudo podman run --rm --entrypoint=/bin/cat \
  docker.io/keeper/guacd:2 \
  /opt/keeper/share/guacd/docker-seccomp.json \
  | sudo tee /etc/kcm-setup/guacd-docker-seccomp.json
```

このコマンドにより一時的なコンテナを起動し、含まれているJSONファイルを読み込んでホストに保存します。

***

## 3. Podmanと補助ツールのインストール

**RHEL / Alma / Rocky / Fedora**

<pre class="language-bash"><code class="lang-bash"><strong>sudo dnf install -y podman podman-compose firewalld haveged
</strong>sudo systemctl enable --now haveged
</code></pre>

**Ubuntu / Debian**

```bash
sudo apt update && sudo apt install -y podman podman-compose firewalld haveged
sudo systemctl enable --now haveged
```

バージョン確認

```bash
podman --version  # バージョン5.x以上であること
```

***

## 4. ComposeファイルをPodman向けに調整

`/opt/kcm/docker-compose.yml`を再度開き、以下の編集を行います。

**セキュリティプロファイル** (`guacd`サービスの下)

```yaml
security_opt:
  - seccomp:/etc/kcm-setup/guacd-docker-seccomp.json
```

**SELinuxホスト (RHEL/Fedora)**\
以下のように各ボリューム定義に `:Z` を追加します。

```yaml
- "common-storage:/var/lib/guacamole:rw,Z"
```

**(任意)** `:latest`タグを`:2`に置き換えることを推奨します (例: `keeper/guacamole:2`)。

***

## 5. Keeperコネクションマネージャーの起動

<pre class="language-bash"><code class="lang-bash"><strong>cd /opt/kcm
</strong>sudo podman-compose up -d
</code></pre>

(DBの初期化に時間がかかる場合は`--time 30`を追加)

起動確認

```bash
podman ps --format "{{.Names}}  {{.Status}}  {{.Ports}}"
```

ブラウザで`http://<server-IP>:8080`にアクセスし、ログイン画面が表示されることを確認します。

***

## 6. ファイアウォールの開放 (RHEL/Fedora)

```bash
sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
```

(UbuntuやDebianでは`ufw`や`nftables`を使用して同様の設定を行います。)

***

## 7. 自動起動の設定

```bash
sudo podman generate systemd --name kcm_guacamole_1 --files --new
sudo podman generate systemd --name kcm_guacd_1      --files --new
sudo podman generate systemd --name kcm_db_1         --files --new
sudo mv *.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now container-kcm_guacamole_1.service \
                       container-kcm_guacd_1.service \
                       container-kcm_db_1.service
```

これで、サーバーの再起動後もKCMが自動で起動します。

***

## 8. 初回起動後の確認

| テスト内容      | コマンド                             | 期待される結果                               |
| ---------- | -------------------------------- | ------------------------------------- |
| ローカルの正常性確認 | `curl -f http://localhost:8080/` | `<title>Guacamole</title>` を含むHTMLを返す |
| コンテナの状態    | `podman ps`                      | 3つのコンテナすべてが「Up」表示                     |
| リモートアクセス   | ブラウザで `http://<server-IP>:8080`  | ログイン画面が表示される                          |

***

### トラブルシューティング

| 問題                            | 原因                                                                                             | 対処法                                                                                      |
| ----------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| 「Connection timed out」        | サーバーのファイアウォールがまだポート8080をブロックしているか、Podmanをrootlessモードで実行しており、ポートが`127.0.0.1`にバインドされている可能性があります。 | Rootfulの場合は手順6のfirewall-cmdを実行。Rootlessの場合はnginxまたはHAProxyを使ってポートを80/443に割り当てる           |
| `/guacamole` で404 Not Found   | UIはデフォルトで `/` に配置されている。                                                                        | `http://host:8080/`にアクセスするか、`guacamole`サービスで`GUACAMOLE_CONTEXT_PATH=guacamole`を設定        |
| Fedora/RHELでPermission denied | SELinuxラベルが不足している。                                                                             | `:Z`を`docker-compose.yml`の各ボリューム行に追加してから`podman-compose down && podman-compose up -d`を実行 |
| 再起動後にサービスが停止死ぬ                | Podman Composeがrestartを無視している。                                                                 | 手順7でsystemdユニットを作成する                                                                     |
| DBが再起動を繰り返す                   | パスワード不一致またはボリューム消失。                                                                            | `POSTGRES_PASSWORD`やその他のデータベース環境変数が、`db`サービスと`guacamole`サービスの両方で一致しているか確認                |

迷ったときは`podman logs <コンテナ名>`を実行して、最後の数行を確認してみてください。多くの場合、原因がわかります。

***

これで、Dockerを使わずにPodman上でKeeperコネクションマネージャーが動作するようになりました。軽量でデーモンレスな構成をお楽しみください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeper-connection-manager/jp/installation/podman-install.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
