用 docker-compose 架設 cmdbuild 及設置自動啟動執行

近日在導入 cmdb 評估了數個方案,發現商用的軟件其實功能強大,也符合公司所需,但價格不便宜,也因此順便比較了幾個開源的軟件做為試行的方案及對比,發現開源部份有個不錯的 CMDB 管理工具,也比較後發現功能強大,但設置真的要花些時間去瞭解上頭的關係及開發客製上的細節, cmdbuild 選擇做為第一個開源試行導入的産品,選擇使用 docker-compose 去進行架設, 基本上不用1分鐘就架設好,真的是懶人的福音.

我的 docker-compose.yml 如下:

version: "3"
services:
  cmdbuild:
    image: quentinv/cmdbuild:latest
    container_name: cmdbuild
    ports:
      - 8080:8080
    networks:
      - cmdbuild-net
  cmdbuild-db:
    image: postgres:9.6.8-alpine
    volumes:
      - /opt/postgresql/data:/var/lib/postgresql/data

    container_name: cmdbuild-db
    environment:
      POSTGRES_PASSWORD: cmdbuild
    networks:
      - cmdbuild-net
networks:
  cmdbuild-net:
    driver: bridge

存檔後直接啟動

docker-compose up -d

建立 /etc/systemd/system/docker-compose-cmdbuild.service

# /etc/systemd/system/docker-compose-cmdbuild.service

[Unit]
Description=Docker Compose Application Service
Requires=docker.service
After=docker.service

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/root/cmdbuild
ExecStart=/usr/local/bin/docker-compose up -d
ExecStop=/usr/local/bin/docker-compose down
TimeoutStartSec=0

[Install]
WantedBy=multi-user.target

然後設置自動啟動服務及開啟防火牆

# systemctl daemon-reload
# systemctl enable docker-compose-cmdbuild.service
# systemctl start docker-compose-cmdbuild.service
# firewall-cmd --permanent --add-port=8080/tcp
# firewall-cmd --reload

完成

Author: jerryw1974

learning and focus on computer science, cloud infrastructure, virtualization and information security, technical, networking,platform system and cyber-security related topic.