Table of Contents
PodmanでNextcloud+ホストで稼働するMySQLを構築
podmanのネットワークの確認
# podman network ls
# podman network inspect podman | grep -e 'gateway' -e 'subnet'
"gateway": "10.88.0.1",
"subnet": "10.88.0.0/16"
MySQLの設定
インストールは、MySQL参照
アドレスは、podmanのネットワーク確認のsubnetを参考にセグメントを指定
# mysql -u root -p
CREATE DATABASE nextcloud CHARACTER SET utf8mb4;
CREATE USER 'hoge'@'10.88.0.%' IDENTIFIED BY '(パスワード)';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'hoge'@'10.88.0.%';
nextcloudとDBの公式イメージを取得
# podman pull docker.io/library/nextcloud:latest
結果を確認
# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/nextcloud latest a4becf970bce 11 hours ago 909 MB
イメージの基本情報を確認
# podman inspect docker.io/library/nextcloud:latest
Pod を作成
# podman pod create -p 8080:80 --name nextcloud-pod
作業フォルダを作成
# mkdir /usr/local/nextcloud
# cd /usr/local/nextcloud
永続化用のフォルダ作成
# mkdir -p /usr/local/nextcloud/data/html
# mkdir -p /usr/local/nextcloud/data/log
コンテナ作成
# podman run --name=nextcloud -d --pod nextcloud-pod \
-d --restart=always \
-e MYSQL_DATABASE="nextcloud" \
-e MYSQL_USER="china" \
-e MYSQL_PASSWORD="sadaaki1" \
-e MYSQL_HOST="192.168.1.7" \
-v /usr/local/nextcloud/data/html:/var/www/html:Z \
-v /usr/local/nextcloud/data/log:/var/log/html:Z \
docker.io/library/nextcloud:latest
結果を確認
# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0d072f3a4a0 k8s.gcr.io/pause:3.5 46 seconds ago Up 13 seconds ago 0.0.0.0:8080->80/tcp 34cdc8586cc1-infra
a6ff0da83c27 docker.io/library/nextcloud:latest apache2-foregroun... 14 seconds ago Up 13 seconds ago 0.0.0.0:8080->80/tcp nextcloud
LOGを確認
# odman logs nextcloud
Initializing nextcloud 24.0.0.12 ...
New nextcloud instance
Initializing finished
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.88.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.88.0.2. Set the 'ServerName' directive globally to suppress this message
[Thu May 05 12:34:22.439122 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/8.0.18 configured -- resuming normal operations
[Thu May 05 12:34:22.439189 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
systemd のUNITファイルを生成+常駐化
# systemctl stop pod-nextcloud-pod.service
# cd /etc/systemd/system
# podman generate systemd --restart-policy no -n -f nextcloud-pod
# systemctl daemon-reload
# systemctl enable pod-nextcloud-pod.service
サービスの起動・停止・ステータス
systemctl stop pod-nextcloud-pod.service
systemctl start pod-nextcloud-pod.service
systemctl status pod-nextcloud-pod.service
初期登録
Kubernetesのyamlファイル作成
# cd /usr/local/nextcloud
# podman generate kube nextcloud-pod > nextcloud-pod.yaml
ポットレベルからの再作成準備(削除)
設定をまとめて削除
# systemctl stop pod-nextcloud-pod.service
# podman pod ls
# podman ps
# podman pod stop nextcloud-pod
# podman pod rm nextcloud-pod
イメージ削除
podman images
podman rmi nextcloud