# 安裝 作業系統 Ubuntu 22.04 LTS 安裝完成 ubuntu 時記的需要更新時區資訊並啟動 ntp 更新機制 ``` sudo timedatectl set-timezone Asia/Taipei ``` <Host 底下接 <Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" /> # 快速安裝方式 Docker、Docker Compose 參考文章 https://docs.docker.com/engine/install/ubuntu/ ``` 1 sudo apt-get update sudo apt-get install ca-certificates curl gnupg 2 sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg 3 echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 4 sudo apt-get install docker docker-compose ``` # 快速安裝 Nagin Proxy Manager 參考以下網址 https://nginxproxymanager.com/setup/ 建立 user nagin 執行目錄就會是 /home/nagin/ Create a docker-compose.yml file: ``` version: '3.8' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: # These ports are in format <host-port>:<container-port> - '80:80' # Public HTTP Port - '443:443' # Public HTTPS Port - '81:81' # Admin Web Port # Add any other Stream port you want to expose # - '21:21' # FTP # Uncomment the next line if you uncomment anything in the section # environment: # Uncomment this if you want to change the location of # the SQLite DB file within the container # DB_SQLITE_FILE: "/data/database.sqlite" # Uncomment this if IPv6 is not enabled on your host # DISABLE_IPV6: 'true' volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt ``` Then docker compose up -d # 如何讓系統啟動時執行 如果您想要在系統啟動時自動執行 `docker-compose up -d`,您可以使用多種方法。其中一種流行的方法是使用 `systemd` 服務。以下是一個簡單的步驟: 1. **創建一個新的 `systemd` 服務檔案** 打開一個文字編輯器以創建一個新的 `systemd` 服務檔案。例如,使用 `sudo nano` 命令: ```bash sudo nano /etc/systemd/system/docker.service ``` 2. **編輯服務檔案** 將以下內容貼入該檔案中,並根據您的具體情況進行適當的調整: ```ini [Unit] Description=Docker Compose Application Service After=network-online.target docker.service Requires=docker.service [Service] WorkingDirectory=/home/nagin/ ExecStart=/usr/bin/docker-compose up -d ExecStop=/usr/bin/docker-compose down Restart=always User=username [Install] WantedBy=multi-user.target ``` - 將 `/path/to/your/docker-compose/directory` 替換為您 `docker-compose.yml` 文件的實際路徑。 - 將 `username` 替換為運行 `docker-compose` 的用戶的用戶名。 3. **重新加載 `systemd` 並啟動服務** ```bash sudo systemctl daemon-reload sudo systemctl start docker.service ``` 4. **設置為開機自啟動** ```bash sudo systemctl enable docker.service ``` 完成以上步驟後,您的 Docker Compose 應用將會在系統啟動時自動運行。 注意:這僅是一個基本的例子,您可能需要根據您的具體需求進行調整。例如,如果您有多個依賴服務,可能需要在 `[Unit]` 部分進行更多配置。