docker-composeでコンテナ作成(Cacti)

6年前にCentOS7.6で構築した検証環境をubuntu22.04.3TLSへ移行するのでメモ

### 環境
仮想化：VMware Workstation-playre17またはVMware workstation-pro17（どちらも確認済み）
ホスト：Windows10またはWindows11pro（どちらも確認済み）
ゲスト：ubuntu22.04.3TLS

### docker-composeでCactiコンテナ作成
``` sh:Cacti用のディレクトリ作成
$ mkdir docker-cacti
```
``` sh:作成したディレクトリへ移動
$ cd docker-cacti
```
``` sh:$ vi docker-compose.yml（ファイル作成：8083は他のコンテナと重複しないportを適宜指定）
version: '3.5'
services:

  cacti:
    image: "gobindacpi/cacti:1"
    container_name: cacti
    domainname: example.com
    hostname: cacti
    ports:
      - "8083:80"
      - "443:443"
    environment:
      - DB_NAME=cacti_master
      - DB_USER=cactiuser
      - DB_PASS=cactipassword
      - DB_HOST=db
      - DB_PORT=3306
      - DB_ROOT_PASS=rootpassword
      - INITIALIZE_DB=1
      - TZ=Asia/Tokyo
    volumes:
      - cacti-data:/cacti
      - cacti-spine:/spine
      - cacti-backups:/backups
    links:
      - db
    restart: always

  db:
    image: "mariadb:10.3"
    container_name: cacti_db
    domainname: example.com
    hostname: db
    ports:
      - "3306:3306"
    command:
      - mysqld
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --max_connections=200
      - --max_heap_table_size=128M
      - --max_allowed_packet=32M
      - --tmp_table_size=128M
      - --join_buffer_size=128M
      - --innodb_buffer_pool_size=1G
      - --innodb_doublewrite=ON
      - --innodb_flush_log_at_timeout=3
      - --innodb_read_io_threads=32
      - --innodb_write_io_threads=16
      - --innodb_buffer_pool_instances=9
      - --innodb_file_format=Barracuda
      - --innodb_large_prefix=1
      - --innodb_io_capacity=5000
      - --innodb_io_capacity_max=10000
    environment:
      - MYSQL_ROOT_PASSWORD=rootpassword
      - TZ=Asia/Tokyo
    volumes:
      - cacti-db:/var/lib/mysql
    restart: always

volumes:
  cacti-db:
  cacti-data:
  cacti-spine:
  cacti-backups:
``` 
``` sh:Docker Composeを使ってRedmineをバックグラウンドで起動
$ docker-compose up -d
```
``` sh:すべてのDockerコンテナの状態を表示
$ docker ps -a
```
### Cacti　WEBUIへアクセス
http://ホストのアドレス:設定したport番号(本環境では8083)
初期ID/PW　admin/admin
変更後PW　Mxxxkxxx3xxx@

### WEBUIで初期設定&インストール
以下、Web上でのインストール画面をキャプチャしたもの。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/7ea2f954-8817-4ded-63e1-e60991ca7250.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/8b8d3399-790a-6d4d-e0e4-1c9b153d8d80.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/298daf2d-2a4e-4736-e688-c2970e19fe42.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/3737fa6b-ff26-f646-826d-47f1cbb76e7e.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/650fb908-90d7-c624-5311-46ffc2bb3e4f.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/96203287-4591-8f09-3986-639bd27e1fc7.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/57633a43-9560-c969-5ad0-2838c0935fb6.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/3bce6167-96a5-ba3d-29bc-b5eab585ef02.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/773e382a-16fa-66a1-58b2-da45de0b6efe.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/7cbcd326-eb8d-c4e2-80bc-194f78443c1b.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/efd7e0ad-68d1-e563-42fa-1f5883f8b392.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/e353a58c-c0cb-2672-084a-9f8fd5674eaa.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/af444e76-1d09-d2d4-13f6-cec6e62a56cb.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/5dbc39d4-a99e-31a8-887e-65f22a9ec944.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/340841/797cc13b-ae79-2d30-20ad-b35ffd36709b.png)

``` sh:$ docker ps -a
CONTAINER ID   IMAGE                               COMMAND                   CREATED        STATUS                  PORTS                                                                          NAMES
9b27ae1c5bad   gobindacpi/cacti:1                  "/start.sh"               4 hours ago    Up 4 hours              0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:8083->80/tcp, :::8083->80/tcp   cacti
e3e5f02cfa34   mariadb:10.3                        "docker-entrypoint.s…"   4 hours ago    Up 4 hours              0.0.0.0:3306->3306/tcp, :::3306->3306/tcp                                      cacti_db
```


### 参考ページ
https://github.com/gobindacpi/cacti-install-on-docker-compose