ข้ามไปที่เนื้อหา
แก้ไขหน้านี้

เริ่มต้นใช้งาน

ฉบับภาษาอังกฤษของหน้านี้ใหม่กว่า อ่านฉบับภาษาอังกฤษ

ข้อกำหนดเบื้องต้น

  • Docker พร้อม ปลั๊กอิน Compose v2 เวอร์ชัน 2.23.1 ขึ้นไป ตรวจสอบได้ ด้วย docker compose version เวอร์ชันที่เก่ากว่านี้อ่านการกำหนดค่าแบบ inline ในไฟล์ compose ไม่ได้ Docker Desktop มีปลั๊กอินนี้มาให้แล้ว หากใช้ Docker Engine เปล่า ๆ บน Linux ให้ติดตั้งจากที่เก็บแพ็กเกจของ Docker (https://docs.docker.com/compose/install/linux/) บน macOS ที่ใช้ Colima ให้ติดตั้งด้วย Homebrew แล้วลิงก์เป็นปลั๊กอินของ Docker:

    brew install docker-compose
    mkdir -p ~/.docker/cli-plugins
    ln -sfn "$(brew --prefix)/opt/docker-compose/bin/docker-compose" ~/.docker/cli-plugins/docker-compose
    
  • โฮสต์ Linux, macOS หรือ Windows (amd64 หรือ arm64)

  • RAM ว่างอย่างน้อย 1 GB สำหรับ CashPilot และบริการที่ CashPilot จัดการ
  • CashPilot หนึ่งชุดต่อหนึ่งโฮสต์ Docker ดูคำเตือนด้านล่าง

CashPilot หนึ่งชุดต่อหนึ่งโฮสต์ Docker

อย่าติดตั้ง CashPilot สองชุดบนโฮสต์ Docker เดียวกัน ไฟล์ compose ใช้ชื่อคอนเทนเนอร์แบบตายตัว (cashpilot-ui, cashpilot-worker, cashpilot-socket-proxy) ไฟล์ชุดที่สองจึงล้มเหลวเพราะชื่อซ้ำกัน หากเปลี่ยนชื่อเพื่อเลี่ยงปัญหานี้ ทั้งสองชุดก็ยังใช้โฮสต์ร่วมกันอยู่ดี เวิร์กเกอร์แต่ละตัวจัดการทุกคอนเทนเนอร์ที่มีป้ายกำกับของ CashPilot ไม่ว่าชุดไหนจะเป็นผู้สร้าง ดังนั้นแดชบอร์ดแต่ละชุดจะแสดง หยุด และแทนที่ แอปหารายได้ของอีกชุดหนึ่ง ทั้งสองชุดยังใช้เครือข่าย cashpilot-isolated ชื่อแอปหารายได้ (cashpilot-<service>) พอร์ตบนโฮสต์ และ volume อย่าง mysterium-data ร่วมกันด้วย หากต้องการติดตั้งชุดที่สอง ให้ใช้โฮสต์หรือ VM อื่น หากต้องการรันแอปหารายได้บนเซิร์ฟเวอร์เพิ่ม ให้เพิ่มเวิร์กเกอร์เข้าแดชบอร์ดเดียวแทน (กลุ่มเครื่อง)

เริ่มต้นอย่างรวดเร็ว

1. ดาวน์โหลดไฟล์ compose แล้วเริ่มระบบ

curl -fsSLO https://raw.githubusercontent.com/GeiserX/CashPilot/main/docker-compose.yml
docker compose up -d

คำสั่งนี้เริ่มคอนเทนเนอร์ที่ทำงานต่อเนื่องสามตัว ก่อนหน้านั้น cashpilot-migrate ซึ่งทำงานครั้งเดียวจะรันแล้วจบด้วยรหัส 0 ทุกครั้งที่ up ดังนั้น docker compose ps -a จะแสดงสถานะเป็น Exited (0) ซึ่งเป็นเรื่องปกติ

คอนเทนเนอร์ พอร์ต หน้าที่
cashpilot-migrate ไม่มี รันครั้งเดียวแล้วจบ ย้ายข้อมูลที่รุ่นเก่าสร้างไว้ไปยัง volume ที่ socket proxy ยอมรับ และไม่มีอะไรต้องทำในการติดตั้งใหม่
cashpilot-ui 8080 แดชบอร์ดเว็บ การเก็บรายได้ แคตตาล็อกบริการ
cashpilot-worker 8081 เอเจนต์ Docker ที่ติดตั้งใช้งานและเฝ้าดูคอนเทนเนอร์ของบริการ
cashpilot-socket-proxy ไม่มี ถือ Docker socket และส่งสำเนาที่กรองแล้วให้เวิร์กเกอร์ (ค่าเริ่มต้นด้านความปลอดภัย)

2. เปิดแดชบอร์ด

เปิด http://localhost:8080 ในเบราว์เซอร์ เนื่องจากยังไม่มีบัญชีใด จึงจะเข้าสู่หน้าต้อนรับ ซึ่งใช้สร้างบัญชีเจ้าของ

พอร์ต 8080 ถูกใช้อยู่แล้วหรือ

เลือกพอร์ตโฮสต์อื่นในไฟล์ .env ที่อยู่ข้าง docker-compose.yml แทนการแก้ไฟล์ compose:

printf '\nCASHPILOT_UI_PORT=8088\n' >> .env
docker compose up -d

จากนั้นเปิด http://localhost:8088 และเก็บค่านี้ไว้ใน .env เพราะ การอัปเดตจากในแอปอ่านไฟล์นั้น ไม่ได้อ่าน shell (printf ขึ้นต้นด้วย การขึ้นบรรทัดใหม่ เพื่อไม่ให้บรรทัดนี้ไปต่อกับบรรทัดสุดท้ายของ .env ที่มีอยู่)

ตัวแปรนี้ต้องใช้ docker-compose.yml ที่บรรทัด ports: เป็น ${CASHPILOT_UI_PORT:-8080}:8080 ไฟล์ของ v1.61 และเก่ากว่ากำหนด 8080:8080 ไว้ตายตัวและไม่สนใจตัวแปรนี้ ให้ดาวน์โหลดไฟล์ปัจจุบัน หรือ เก็บการแมปพอร์ตที่แก้ไว้เองก็ได้ การอัปเดตจากในแอปยอมรับแบบนั้นเช่นกัน

ต้องใช้โทเค็นตั้งค่าในการเริ่มใช้งานครั้งแรก

เมื่อเริ่มครั้งแรก CashPilot จะสร้างโทเค็นตั้งค่าแบบใช้ครั้งเดียว และพิมพ์ไว้ในบันทึกของคอนเทนเนอร์ cashpilot-ui:

docker compose logs cashpilot-ui

มองหาบรรทัดลักษณะนี้:

FIRST-RUN SETUP: no account exists yet. Open /register and enter this
one-time setup token to create the owner account: <token>

คัดลอกโทเค็นนั้นไปใส่ในช่อง Setup token (โทเค็นตั้งค่า) ในขั้นตอน Owner account (บัญชีเจ้าของ) ของหน้าต้อนรับ พร้อมชื่อผู้ใช้และรหัสผ่าน เพื่อสร้างบัญชีแรก (บัญชีเจ้าของ) โทเค็นนี้แสดงเฉพาะในบันทึกเท่านั้น ไม่เคยอยู่ใน URL และถูกทิ้งอย่างถาวรเมื่อมีบัญชีเจ้าของแล้ว

3. เรียกดูแคตตาล็อกบริการ

หน้า Catalog (แคตตาล็อก) แสดงทุกบริการ พร้อมแพลตฟอร์ม ค่าประมาณรายเดือน และสิ่งที่บริการต้องการ (IP ที่อยู่อาศัย, GPU) กรองตามหมวดหมู่ (Bandwidth, DePIN, Storage, Compute, Mining) หรือค้นหาตามชื่อได้ Add (เพิ่ม) เปิดตัวช่วยตั้งค่าที่บริการนั้น Details (รายละเอียด) แสดงคำอธิบาย การจ่ายเงิน และความเสี่ยงในการติดตั้งใช้งาน ส่วนบริการที่ไม่ได้รันใน Docker จะมีลิงก์ Visit (เยี่ยมชม) แทน

บริการสองประเภทควรตรวจสอบให้ละเอียดก่อน ได้แก่ บริการที่จ่ายเงินหลังจากล็อกโทเค็นเป็นเงินวางค้ำ (stake) แล้วเท่านั้น เช่น Anyone Protocol, Sia และ Flux และรีเลย์ที่เผยแพร่ IP ของคุณ ซึ่งอาจทำให้แอปแบนด์วิดท์แบบที่อยู่อาศัยจ่ายน้อยลง ดู ตรวจสอบสองเรื่องก่อนติดตั้งใช้งาน

4. เพิ่มบริการด้วยตัวช่วยตั้งค่า

เมื่อมีบัญชีเจ้าของแล้ว Add services (เพิ่มบริการ) จะเปิดตัวช่วยตั้งค่า หลังจากนั้นปุ่ม + Add service (+ เพิ่มบริการ) ที่แถบด้านบนจะเปิดตัวช่วยอีกครั้ง เลือกหมวดหมู่ แล้วเลือกบริการ สำหรับแต่ละบริการ ตัวช่วยจะแสดงลิงก์ Sign Up (สมัคร) ถามเฉพาะข้อมูลรับรองที่บริการนั้นต้องการ (อีเมลและรหัสผ่าน โทเค็น API เป็นต้น) และให้เลือกเวิร์กเกอร์ที่จะรันบริการนั้น คลิก Deploy (ติดตั้งใช้งาน) แล้ว CashPilot จะดึงอิมเมจ สร้างคอนเทนเนอร์ และเริ่มเฝ้าดู

5. ติดตามบนแดชบอร์ด

แดชบอร์ดแสดงแต่ละบริการที่ติดตั้งใช้งานแล้วพร้อมสถานะและยอดคงเหลือ และหน้า Fleet (กลุ่มเครื่อง) แสดงเวิร์กเกอร์ทุกตัว

วิธีการทำงาน

graph LR
    A[User] -->|Browse & Configure| B[CashPilot UI<br>Port 8080]
    B -->|Deploy Commands| C[CashPilot Worker<br>Port 8081]
    C -->|Docker API| D[Service Containers]
    D -->|Health & Status| C
    C -->|Heartbeat| B
    B -->|Collect Earnings| E[Service APIs]
    E -->|Balance Data| B
  1. คุณกำหนดค่า บริการผ่านเว็บ UI -- เลือกบริการ ใส่ข้อมูลรับรอง คลิกติดตั้งใช้งาน
  2. UI ส่ง สเปกของคอนเทนเนอร์ (อิมเมจ, ตัวแปรสภาพแวดล้อม, volume) ไปยังเวิร์กเกอร์ผ่าน REST API
  3. เวิร์กเกอร์สร้าง คอนเทนเนอร์ Docker และเริ่มเฝ้าดูสุขภาพ
  4. เวิร์กเกอร์รายงาน สถานะคอนเทนเนอร์กลับไปยัง UI ทุก 60 วินาทีผ่านสัญญาณชีพ
  5. UI เก็บ รายได้จาก API ของบริการตามกำหนดเวลาที่ปรับได้ (ค่าเริ่มต้น: ทุกชั่วโมง)
  6. แดชบอร์ด แสดงรายได้รวม รายละเอียดแยกตามบริการ และสุขภาพของคอนเทนเนอร์

การกำหนดค่า

ตัวแปรสภาพแวดล้อมของ UI

ตัวแปร ค่าเริ่มต้น คำอธิบาย
TZ UTC เขตเวลาสำหรับการตั้งเวลาและการแสดงผล
CASHPILOT_SECRET_KEY (สร้างอัตโนมัติ) คีย์ลงนามสำหรับเซสชันการเข้าสู่ระบบ เก็บไว้ที่ /data/.secret_key ไม่ได้เข้ารหัสข้อมูลรับรอง
CASHPILOT_ENCRYPTION_KEY (สร้างอัตโนมัติ) คีย์ Fernet ที่เข้ารหัสข้อมูลรับรองที่จัดเก็บไว้ เก็บไว้ที่ /data/.fernet_key ใช้เฉพาะเมื่อไม่มีไฟล์นั้น และไม่เคยถูกเขียนลงใน /data ส่วน CASHPILOT_ENCRYPTION_KEY_FILE (พาธ) มีลำดับความสำคัญเหนือกว่าทั้งสองอย่าง: ดู คีย์เข้ารหัสนอกโฟลเดอร์ข้อมูล
CASHPILOT_API_KEY (จาก /fleet) คีย์ลงทะเบียนที่ใช้ร่วมกันสำหรับเวิร์กเกอร์ เวิร์กเกอร์แต่ละตัวจะได้คีย์ของตัวเองเมื่อลงทะเบียน ดู กลุ่มเครื่อง
CASHPILOT_COLLECT_INTERVAL 60 จำนวนนาทีระหว่างรอบการเก็บรายได้
CASHPILOT_UI_PORT 8080 พอร์ตโฮสต์ที่เผยแพร่ UI ตั้งค่าใน .env เมื่อพอร์ต 8080 ถูกใช้อยู่
CASHPILOT_BIND_ADDR 127.0.0.1 อินเทอร์เฟซของโฮสต์ที่เผยแพร่พอร์ต UI ค่าเริ่มต้นคือ loopback: แดชบอร์ดสั่งงานเวิร์กเกอร์ที่เข้าถึง Docker socket ได้ จึงไม่เปิดให้เครือข่ายเข้าถึงตั้งแต่แรก ตั้งค่าเป็น IP ที่ระบุ (เช่น ที่อยู่ Tailscale/VPN) หรือ 0.0.0.0 เพื่อเปิดให้เข้าถึง หรือ (แนะนำ) ใช้ reverse proxy ที่มีการยืนยันตัวตนไว้ด้านหน้า

พอร์ตเว็บของ UI ภายในคอนเทนเนอร์กำหนดตายตัวที่ 8080 (ตั้งผ่าน CMD ของคอนเทนเนอร์) CASHPILOT_UI_PORT และ CASHPILOT_BIND_ADDR เลือกเพียงพอร์ตและอินเทอร์เฟซของโฮสต์ที่ใช้เผยแพร่เท่านั้น

ตัวแปรสภาพแวดล้อมของเวิร์กเกอร์

ตัวแปร ค่าเริ่มต้น คำอธิบาย
TZ UTC เขตเวลา
CASHPILOT_UI_URL -- URL ของคอนเทนเนอร์ UI เช่น http://cashpilot-ui:8080
CASHPILOT_API_KEY -- ต้องตรงกับคีย์ลงทะเบียนของ UI ใช้เฉพาะตอนลงทะเบียน หลังจากนั้นเวิร์กเกอร์ใช้คีย์ของตัวเอง
CASHPILOT_WORKER_NAME (hostname) ชื่อที่แสดงของเวิร์กเกอร์นี้ในแดชบอร์ดกลุ่มเครื่อง
CASHPILOT_WORKER_URL (ตรวจหาอัตโนมัติ) URL ที่ UI ใช้เข้าถึงเวิร์กเกอร์นี้ เช่น http://192.168.1.50:8081 ควรกำหนดเองสำหรับกลุ่มเครื่องข้ามโฮสต์ เพราะการตรวจหาอัตโนมัติอาจรายงาน IP ภายในคอนเทนเนอร์ที่เข้าถึงไม่ได้
CASHPILOT_WORKER_BIND_ADDR 127.0.0.1 ใช้กับ compose ของกลุ่มเครื่องและเวิร์กเกอร์ระยะไกลเท่านั้น (docker-compose.fleet.yml): อินเทอร์เฟซของโฮสต์ที่เผยแพร่พอร์ต API ของเวิร์กเกอร์ซึ่งเข้าถึง Docker socket ได้ ค่าเริ่มต้นคือ loopback ส่วน docker-compose.yml ค่าเริ่มต้นไม่ได้เผยแพร่พอร์ต 8081 เลย API ของเวิร์กเกอร์ติดตั้งใช้งานหรือหยุดคอนเทนเนอร์ใดก็ได้ (= root บนโฮสต์) ดังนั้นสำหรับเวิร์กเกอร์ระยะไกล ให้ผูกกับอินเทอร์เฟซส่วนตัวหรือ VPN (เช่น IP ของ Tailscale) ห้าม ใช้ IP สาธารณะ
CASHPILOT_PORT 8081 พอร์ตที่เวิร์กเกอร์ ประกาศ ให้ UI ทราบ ค่านี้ ไม่ได้ เปลี่ยนพอร์ตที่รับฟัง ซึ่งกำหนดตายตัวโดย CMD ของอิมเมจ ดู ข้อมูลอ้างอิงการกำหนดค่า

ตัวอย่าง Docker Compose

# CashPilot - Self-hosted passive income orchestrator
# https://github.com/GeiserX/CashPilot
#
# UI + Worker on the same server. For multi-server fleet, see docker-compose.fleet.yml
#
#   Start / update:  docker compose pull && docker compose up -d
#
# ONE CashPilot per Docker host. The container names in this file are fixed,
# and a worker manages every container on its Docker engine that carries
# CashPilot's labels, whichever install made it. A second install on the same
# host would list, stop and replace the first one's earners. Put it on another
# host or VM. docs/getting-started.md has the details.
#
# Images are PINNED to a major.minor tag, which is what the lines below say.
# `docker compose pull && up -d` therefore gets the newest patch of that series,
# not the newest release overall. To move to a newer series, read UPGRADING.md
# first, then edit the tags on the UI host first and on every worker after it.
#
# This header used to claim the file tracked `latest` while pinning 1.4, and the
# string `:latest` it told you to replace did not appear anywhere. Following the
# quickstart therefore installed a version many releases behind, and issue #188
# is someone hitting a first-run bug that had been fixed for months because of
# it. Keep this comment honest about what the file actually does.
# See https://hub.docker.com/r/drumsergio/cashpilot/tags for available tags.
# NOTE: versions before 1.0.0 predate the per-worker fleet-key auth cutover and
# are not compatible with a worker running 1.x -- pin UI and worker together.
# Building from source? Use: docker compose -f docker-compose.build.yml up -d

services:
  cashpilot-ui:
    image: drumsergio/cashpilot:3.3
    pull_policy: always
    container_name: cashpilot-ui
    # Published on loopback by default: the dashboard can command the Docker-socket
    # worker, so it must not be exposed to your LAN/the internet out of the box.
    # To reach it from another machine, point CASHPILOT_BIND_ADDR at a specific
    # interface (e.g. a Tailscale/VPN IP) or, better, run an authenticating reverse
    # proxy in front. CASHPILOT_BIND_ADDR=0.0.0.0 publishes on all interfaces.
    # Host port 8080 already taken? Set CASHPILOT_UI_PORT=8088 (and CASHPILOT_BIND_ADDR)
    # in a .env file next to this compose file, not on the command line. The in-app
    # update reads .env and never sees your shell. The container port stays 8080.
    ports:
      - "${CASHPILOT_BIND_ADDR:-127.0.0.1}:${CASHPILOT_UI_PORT:-8080}:8080"
    volumes:
      - cashpilot_data:/data
      - cashpilot_fleet_owned:/fleet
    environment:
      - TZ=${TZ:-UTC}
      - CASHPILOT_SECRET_KEY=${CASHPILOT_SECRET_KEY:-}
      # Optional: only needed to RESTORE credentials onto a fresh volume.
      # An existing /data/.fernet_key always wins, so setting this is safe.
      - CASHPILOT_ENCRYPTION_KEY=${CASHPILOT_ENCRYPTION_KEY:-}
      - CASHPILOT_ALLOW_EPHEMERAL_KEY=${CASHPILOT_ALLOW_EPHEMERAL_KEY:-false}
      - CASHPILOT_API_KEY=${CASHPILOT_API_KEY:-}
      - CASHPILOT_ADMIN_API_KEY=${CASHPILOT_ADMIN_API_KEY:-}
      # Optional bearer key for reporting only (Home Assistant, Grafana,
      # cashpilot-mcp with CASHPILOT_READ_ONLY=true). See docs/configuration.md.
      - CASHPILOT_READONLY_API_KEY=${CASHPILOT_READONLY_API_KEY:-}
      # Optional Prometheus /metrics. true serves it; set a token to require
      # Authorization: Bearer. See docs/guides/prometheus-metrics.md.
      - CASHPILOT_METRICS_ENABLED=${CASHPILOT_METRICS_ENABLED:-false}
      - CASHPILOT_METRICS_TOKEN=${CASHPILOT_METRICS_TOKEN:-}
      # Optional CAPTCHA on the sign-in page, for a UI the internet can reach:
      # turnstile, hcaptcha or recaptcha (v2 checkbox), plus both keys. Empty = off.
      # See docs/security-defaults.md, "Protect the sign-in page with a CAPTCHA".
      - CASHPILOT_CAPTCHA_PROVIDER=${CASHPILOT_CAPTCHA_PROVIDER:-}
      - CASHPILOT_CAPTCHA_SITE_KEY=${CASHPILOT_CAPTCHA_SITE_KEY:-}
      - CASHPILOT_CAPTCHA_SECRET_KEY=${CASHPILOT_CAPTCHA_SECRET_KEY:-}
      # Warn when a container misses a later catalog fix. false turns it off.
      - CASHPILOT_DRIFT_WARNINGS=${CASHPILOT_DRIFT_WARNINGS:-true}
    init: true
    # The image declares its own HEALTHCHECK, so `docker ps` will show
    # "(unhealthy)" when the app stops answering. NOTHING ACTS ON THAT BY
    # DEFAULT: `restart: unless-stopped` restarts a container that EXITS, and a
    # container failing its healthcheck is still running. It will sit there
    # unhealthy indefinitely. (Docker Swarm reschedules unhealthy tasks; plain
    # Compose does not.)
    #
    # To act on it, either alert on it -- see the CashPilotDown rule in
    # docs/guides/prometheus-metrics.md -- or add an autoheal sidecar, which is
    # documented in the same place along with the fact that it needs the Docker
    # socket, i.e. root on the host.
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    tmpfs:
      - /tmp:size=64M
    # cashpilot_fleet_owned is filled by cashpilot-migrate on an upgrade.
    depends_on:
      cashpilot-migrate:
        condition: service_completed_successfully
    # Where the UI reaches the worker. Labelled for the proxy, so the in-app
    # update may attach the worker to it.
    networks:
      - cashpilot_owned

  # Runs once at every `docker compose up`, before the proxy, and exits.
  # Releases before owner isolation made volumes and the LAN fence's network
  # without the proxy's owner label, and Docker cannot add a label later, so
  # this copies each one to a backup, recreates it with the label, copies the
  # data back and checks it, then recreates the service container as it was.
  # The backups (<volume>-pre-isolation) and the volumes this file renamed are
  # never deleted: UPGRADING.md says how to remove them. It holds the raw
  # socket only while it runs; a second run finds nothing to do.
  cashpilot-migrate:
    image: drumsergio/cashpilot-worker:3.3
    pull_policy: always
    container_name: cashpilot-migrate
    user: "0:0"
    entrypoint: ["python", "-m", "app.owner_migrate"]
    environment:
      # old=new compose volume keys: the data moves into the labelled volume.
      - CASHPILOT_MIGRATE_COMPOSE_VOLUMES=cashpilot_worker_data=cashpilot_worker_data_owned,cashpilot_fleet=cashpilot_fleet_owned
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      # Each step it finished, so a run killed halfway is completed by the next.
      # A folder, not a volume: the in-app update runs docker compose through
      # the proxy, and Compose checks every volume of the worker's dependencies,
      # this one included, which the proxy will not let the worker see.
      - ./cashpilot-migrate-state:/state
    network_mode: none
    restart: "no"
    healthcheck:
      disable: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true

  # Holds the host's Docker socket so the worker does not have to. It serves
  # a filtered copy in the cashpilot_docker_api volume and refuses every call
  # the worker does not make: a privileged container, a bind of / or of the
  # socket, a capability or device outside the catalog's, exec of anything but
  # the catalog's readers, swarm, plugins, builds. The policy is the configs
  # block at the end of this file. docs/security-defaults.md has the details.
  #
  # Pinned by digest and bumped on purpose; the in-app update never recreates
  # it (it runs `up --no-deps` on the UI and worker only).
  cashpilot-socket-proxy:
    image: codeswhat/sockguard:2.4.10@sha256:af66f6dcab2d6c04c4a45823ea9b72549985bf1957dea3bb4382c1515ab9461e
    container_name: cashpilot-socket-proxy
    # Root with no capabilities: uid 0 opens the root-owned host socket, and
    # group 1000 (the worker's) lets it give the worker its socket.
    user: "0:0"
    group_add:
      - "1000"
    cap_drop:
      - ALL
    # One capability it never uses, and that no container the worker creates
    # may ask for. A container that joins this one's process namespace then
    # holds less than the proxy does, so the kernel refuses it the proxy's
    # files (/proc/1/root), the host socket among them.
    cap_add:
      - WAKE_ALARM
    security_opt:
      - no-new-privileges:true
    # Unix sockets only; it needs no network at all.
    network_mode: none
    restart: unless-stopped
    # It peaks near 45 MB, streams included; the cap only stops a leak
    # from taking the host's memory with it.
    mem_limit: 256m
    # One log line per Docker call (refusals included), so the log is capped.
    logging:
      driver: json-file
      options:
        max-size: "5m"
        max-file: "2"
    # `sockguard verify` asks the host's Docker through the socket this proxy
    # holds, so a stale or missing host socket (a Docker update replaced it,
    # docs/faq.md) turns it unhealthy. Exec form: the image has no shell.
    healthcheck:
      test: ["CMD", "/sockguard", "verify"]
      interval: 60s
      timeout: 10s
      retries: 3
      start_period: 20s
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - cashpilot_docker_api:/run/cashpilot-docker
    environment:
      # Host paths containers may bind: your compose folder (the in-app
      # update needs it) and each folder a service keeps its data in (Storj's
      # identity and data folders, for example), comma-separated. Set both in
      # the .env next to this file. The proxy binds a listed path only as
      # itself, never a folder under it, so list every path a service binds.
      # Write each as an exact absolute path, with no trailing slash, `//`, `.`
      # or `..`: the proxy refuses to start on any other spelling.
      # The placeholders sit under /dev/null, where no directory can ever exist
      # (Docker cannot create one there), so an unset variable allows nothing.
      - SOCKGUARD_REQUEST_BODY_CONTAINER_CREATE_ALLOWED_BIND_MOUNTS=${CASHPILOT_COMPOSE_DIR:-/dev/null/cashpilot-compose-dir-unset},${CASHPILOT_PROXY_BIND_MOUNTS:-/dev/null/cashpilot-bind-mounts-unset}
      # The policy's fingerprint. Compose does not recreate a container when
      # only its config's content changes, so this line is what makes
      # `docker compose up -d` restart the proxy on a new policy.
      - CASHPILOT_PROXY_POLICY=bf36af85a1e0f393
    configs:
      - source: cashpilot_socket_policy
        target: /etc/sockguard/sockguard.yaml
    depends_on:
      cashpilot-migrate:
        condition: service_completed_successfully

  cashpilot-worker:
    image: drumsergio/cashpilot-worker:3.3
    pull_policy: always
    container_name: cashpilot-worker
    # The proxy's owner label: the worker may read its own container, and the
    # in-app update may recreate it through the proxy.
    labels:
      cashpilot.deployed-by: worker
    expose:
      - "8081"
      # The worker reads host GPU information from sysfs. Leave the GPU
      # devices on the host so it can grant them to catalog services
      # that declare docker.gpu. See docs/gpu.md.
    volumes:
      # No Docker socket here: the worker reaches Docker through the proxy's
      # filtered socket in this volume (DOCKER_HOST below).
      - cashpilot_docker_api:/run/cashpilot-docker
      # SEPARATE FROM THE UI'S /data, DELIBERATELY. This container drives
      # Docker, so a flaw in it reaches the host. The UI's /data holds
      # cashpilot.db and .fernet_key -- the credential store and the only key
      # that can decrypt it -- and the component that can start any container
      # on the machine has no business being able to read them.
      #
      # /fleet IS shared on purpose: it holds only the shared enrolment key,
      # which both sides need by definition.
      #
      # Consolidating these into one volume is the obvious "simplification" and
      # it silently removes that boundary. tests/test_beads_batch_69.py fails if
      # anyone does.
      - cashpilot_worker_data_owned:/data
      - cashpilot_fleet_owned:/fleet
    environment:
      - TZ=${TZ:-UTC}
      - CASHPILOT_UI_URL=http://cashpilot-ui:8080
      - CASHPILOT_API_KEY=${CASHPILOT_API_KEY:-}
      - CASHPILOT_WORKER_NAME=local
      - CASHPILOT_MINERS=${CASHPILOT_MINERS:-}
      - DOCKER_HOST=unix:///run/cashpilot-docker/docker.sock
      # The proxy policy's fingerprint (scripts/socket_proxy_policy.py), so the
      # worker can say when its image needs a newer policy than this file has.
      - CASHPILOT_PROXY_POLICY=bf36af85a1e0f393
      # The same two values the proxy gets, so the worker can say what to set
      # before the proxy refuses (the in-app update, a host-folder bind).
      - CASHPILOT_COMPOSE_DIR=${CASHPILOT_COMPOSE_DIR:-}
      - CASHPILOT_PROXY_BIND_MOUNTS=${CASHPILOT_PROXY_BIND_MOUNTS:-}
      # Earners are fenced off your LAN and this host by default (docs/isolation.md).
      # off keeps Docker's default bridge.
      - CASHPILOT_ISOLATION=${CASHPILOT_ISOLATION:-auto}
      - CASHPILOT_DRIFT_WARNINGS=${CASHPILOT_DRIFT_WARNINGS:-true}
    depends_on:
      - cashpilot-socket-proxy
    init: true
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    tmpfs:
      - /tmp:size=64M
    # Labelled for the proxy, so the in-app update may attach the worker to it.
    networks:
      - cashpilot_owned

volumes:
  cashpilot_data:
  # The worker's own data and the enrolment key it shares with the UI. They
  # carry the proxy's owner label, so the in-app update may mount them. Compose
  # never relabels a volume, so they are new ones: cashpilot-migrate copied
  # cashpilot_worker_data and cashpilot_fleet into them and left the old ones
  # as backups. The UI's cashpilot_data never carries the label.
  cashpilot_worker_data_owned:
    labels:
      cashpilot.deployed-by: worker
  cashpilot_fleet_owned:
    labels:
      cashpilot.deployed-by: worker
  # Fixed name: the in-app update mounts it by name to reach the proxy. It
  # replaced cashpilot-docker-api, which held nothing but the socket.
  cashpilot_docker_api:
    name: cashpilot-docker-api-owned
    labels:
      cashpilot.deployed-by: worker

networks:
  cashpilot_owned:
    labels:
      cashpilot.deployed-by: worker

# The Docker socket proxy's policy. scripts/socket_proxy_policy.py writes it
# from the catalog; `$$` is how compose spells a literal `$`. Needs Docker
# Compose 2.23.1 or newer (inline config content).
configs:
  cashpilot_socket_policy:
    content: |
      # BEGIN socket proxy policy: written by scripts/socket_proxy_policy.py, do not edit by hand
      listen:
        socket: /run/cashpilot-docker/docker.sock
        # The worker runs as uid/gid 1000 (Dockerfile.worker). The proxy runs as
        # root with no capabilities and joins group 1000, so it can hand the socket
        # to that group without asking for the host's docker group id.
        socket_mode: "0660"
        socket_gid: 1000
      upstream:
        socket: /var/run/docker.sock
        # Image pulls and container waits take minutes; the default cuts them at 60 s.
        request_timeout: "off"
      log:
        level: info
        format: json
        # One line per call, refusals included: docker logs cashpilot-socket-proxy
        # shows what was refused and why. The compose file caps the log's size.
        access_log: true
      health:
        enabled: false
      # The worker reads its own containers' logs and files (backups, the update check).
      insecure_allow_read_exfiltration: true
      response:
        # A refusal carries the rule's reason, which the worker shows to you.
        deny_verbosity: verbose
        # The worker reads Env, Mounts and IPAM back (recreates, the isolation check).
        redact_container_env: false
        redact_mount_paths: false
        redact_network_topology: false
      request_body:
        container_create:
          allow_privileged: false
          # The LAN fence helper and the isolation check's control probe run on the
          # host network; no earner does (the worker refuses it for every catalog
          # service, and the catalog refuses it to any service with NET_ADMIN).
          allow_host_network: true
          allow_host_pid: false
          allow_host_ipc: false
          allow_host_userns: false
          allow_host_cgroupns: false
          allowed_capabilities: [NET_ADMIN, NET_RAW, SETUID, SETGID]
          allowed_devices: [/dev/net/tun, /dev/dri/renderD128, /dev/dri/renderD129, /dev/dri/renderD130, /dev/dri/renderD131, /dev/dri/renderD132, /dev/dri/renderD133, /dev/dri/renderD134, /dev/dri/renderD135, /dev/kfd, /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2, /dev/ttyUSB3, /dev/ttyUSB4, /dev/ttyUSB5, /dev/ttyUSB6, /dev/ttyUSB7, /dev/ttyUSB8, /dev/ttyUSB9, /dev/ttyACM0, /dev/ttyACM1, /dev/ttyACM2, /dev/ttyACM3, /dev/ttyACM4, /dev/ttyACM5, /dev/ttyACM6, /dev/ttyACM7, /dev/ttyACM8, /dev/ttyACM9]
          allowed_device_requests: [{driver: nvidia, allowed_capabilities: [[gpu]]}]
          allowed_runtimes: [runc, runsc, runsc-hostnet, runsc-hostnet-raw]
          allow_sysctls: true               # the tunnel sidecar turns IPv6 off in its own namespace
          require_no_new_privileges: true
          deny_unconfined_seccomp: true
          deny_unconfined_apparmor: true
          deny_unconfined_system_paths: true
          # Host folders containers may bind come from CASHPILOT_COMPOSE_DIR and
          # CASHPILOT_PROXY_BIND_MOUNTS, through the proxy service's environment.
          allowed_bind_mounts: []
        container_remove:
          allow_force: true
          allow_remove_volumes: true
        container_archive:
          # The only folder the worker writes into a container: the tunnel
          # sidecar's proxy settings.
          allowed_paths: [/run/cashpilot-secret]
          allow_setid: false
          allow_device_nodes: false
          allow_escaping_links: false
        exec:
          allow_privileged: false
          allow_root_user: true
          # The worker's exec calls send no environment. This name is never sent,
          # so any Env entry (PATH, LD_PRELOAD) is refused.
          allowed_env_vars: [CASHPILOT_EXEC_SENDS_NO_ENV]
          allowed_commands:
            - ["cat", "/run/ready"]
            - ["sh", "-c", "id=$$(wget -qO- -T 5 http://127.0.0.1:4050/identities | grep -o '0x[0-9a-fA-F]\\{40\\}' | head -1) && wget -qO- -T 5 \"http://127.0.0.1:4050/identities/$$id\" && { echo; wget -qO- -T 5 \"http://127.0.0.1:4050/transactor/settle/history?page_size=1000\" || true; }"]
            - ["sh", "-c", "id=$$(wget -qO- -T 5 http://127.0.0.1:4050/identities | grep -o '0x[0-9a-fA-F]\\{40\\}' | head -1) && wget -qO- -T 5 \"http://127.0.0.1:4050/identities/$$id/beneficiary\""]
            - ["timeout", "12", "sh", "-c", "if m=$$(wget -qO- -Y off -T 5 http://127.0.0.1:4050/node/monitoring-status); then\n  echo \"monitoring read: $$m\"\nfi\nset -o pipefail\nif s=$$(wget -qO- -Y off -T 5 \"http://127.0.0.1:4050/sessions?direction=Provided&status=Completed&page_size=100\") &&\n  sorted=$$(echo \"$$s\" | sed 's/},{/}\\n{/g' | awk '\n    match($$0, /\"created_at\":\"[^\"]+\"/) {\n      t = substr($$0, RSTART + 14, 19); gsub(/[-T:]/, \" \", t)\n      d = 0; if (match($$0, /\"duration\":[0-9]+/)) d = substr($$0, RSTART + 11, RLENGTH - 11)\n      print mktime(t) + d, $$0\n    }' | sort -rn); then\n  [ -z \"$$sorted\" ] || echo \"$$sorted\" | head -5\n  echo \"sessions read: all\"\nfi"]
            - ["sh", "-c", "T=\"\"; command -v timeout >/dev/null 2>&1 && T=\"timeout 5\"; $$T iptables-nft -t nat -S MYST 2>/dev/null; if grep -qx nat /proc/net/ip_tables_names 2>/dev/null; then $$T iptables-legacy -t nat -S MYST 2>/dev/null; $$T iptables -t nat -S MYST 2>/dev/null; else case \"$$($$T iptables -V 2>/dev/null)\" in *nf_tables*) $$T iptables -t nat -S MYST 2>/dev/null;; esac; fi"]
            - ["cat", "/etc/anon/anonrc"]
        image_pull:
          allow_all_registries: true        # catalog and custom services come from many registries
        network:
          # The LAN fence (app/lan_fence.py) creates its bridge with three driver
          # options (interface name, no masquerade, no inter-container traffic) and
          # moves an earner across with a forced disconnect. Custom drivers, swarm
          # scope, custom IPAM and endpoint settings stay refused.
          allow_driver_options: true
          allow_disconnect_force: true
        volume:
          # Plain local volumes only: driver options could point one at a host folder.
          allow_custom_drivers: false
          allow_driver_opts: false
      # The worker sees and touches only what carries the owner label below: what
      # it created through this proxy, and what app/owner_migrate.py labelled. The
      # UI's container and its data volume never carry it.
      ownership:
        owner: worker
        label_key: cashpilot.deployed-by
        # Images carry no owner: one pulled for an earner is shared with the host.
        allow_unowned_images: true
        allow_cross_owner_namespace_sharing: false
      rules:
        - {match: {method: GET, path: "/_ping"}, action: allow}
        - {match: {method: HEAD, path: "/_ping"}, action: allow}
        - {match: {method: GET, path: "/version"}, action: allow}
        - {match: {method: GET, path: "/info"}, action: allow}
        - {match: {method: GET, path: "/containers/json"}, action: allow}
        - {match: {method: GET, path: "/containers/*/json"}, action: allow}
        - {match: {method: POST, path: "/containers/create"}, action: allow}
        - {match: {method: POST, path: "/containers/*/start"}, action: allow}
        - {match: {method: POST, path: "/containers/*/stop"}, action: allow}
        - {match: {method: POST, path: "/containers/*/restart"}, action: allow}
        - {match: {method: POST, path: "/containers/*/pause"}, action: allow}
        - {match: {method: POST, path: "/containers/*/unpause"}, action: allow}
        - {match: {method: POST, path: "/containers/*/wait"}, action: allow}
        - {match: {method: POST, path: "/containers/*/rename"}, action: allow}
        - {match: {method: DELETE, path: "/containers/*"}, action: allow}
        - {match: {method: GET, path: "/containers/*/logs"}, action: allow}
        - {match: {method: GET, path: "/containers/*/stats"}, action: allow}
        - {match: {method: GET, path: "/containers/*/archive"}, action: allow}
        - {match: {method: PUT, path: "/containers/*/archive"}, action: allow}
        - {match: {method: POST, path: "/containers/*/exec"}, action: allow}
        - {match: {method: POST, path: "/exec/*/start"}, action: allow}
        - {match: {method: GET, path: "/exec/*/json"}, action: allow}
        - {match: {method: GET, path: "/images/**/json"}, action: allow}
        - {match: {method: POST, path: "/images/create"}, action: allow}
        - {match: {method: GET, path: "/networks"}, action: allow}
        - {match: {method: GET, path: "/networks/*"}, action: allow}
        - {match: {method: POST, path: "/networks/create"}, action: allow}
        - {match: {method: POST, path: "/networks/*/connect"}, action: allow}
        - {match: {method: POST, path: "/networks/*/disconnect"}, action: allow}
        - {match: {method: DELETE, path: "/networks/*"}, action: allow}
        - {match: {method: POST, path: "/volumes/create"}, action: allow}
        - {match: {method: GET, path: "/volumes/*"}, action: allow}
        - {match: {method: DELETE, path: "/volumes/*"}, action: allow}
        - {match: {method: "*", path: "/**"}, action: deny, reason: "the CashPilot worker does not use this Docker API call"}
      # END socket proxy policy

นี่คือไฟล์จริง

บล็อกด้านบนดึงมาจาก docker-compose.yml ในที่เก็บโค้ดแบบคำต่อคำ จึงไม่มีทางคลาดเคลื่อนจากสิ่งที่เผยแพร่จริง ก่อนหน้านี้ ฉบับที่คัดลอกด้วยมือ เคยเผยแพร่ API ของเวิร์กเกอร์ซึ่งเข้าถึง Docker socket ได้บนทุกอินเทอร์เฟซ และปักหมุด :latest ซึ่งทั้งสองอย่างเป็นสิ่งที่หน้า ค่าเริ่มต้นด้านความปลอดภัย บอกว่าไม่ควรทำ

การเข้าถึง Docker Socket

เวิร์กเกอร์จัดการคอนเทนเนอร์ของบริการผ่าน Docker แต่ไม่ได้ mount /var/run/docker.sock คอนเทนเนอร์ cashpilot-socket-proxy ถือ socket ไว้และส่งต่อให้เวิร์กเกอร์เฉพาะคำสั่งที่เวิร์กเกอร์ใช้ โดยปฏิเสธคอนเทนเนอร์แบบ privileged และการ bind โฟลเดอร์ของโฮสต์ที่ไม่ได้ระบุไว้ (สิ่งที่ถูกปฏิเสธ) การอัปเดตจากในแอปต้องเปิดใช้เอง: ทำงานเฉพาะเมื่อมี CASHPILOT_COMPOSE_DIR=<this folder> ใน .env ข้างไฟล์ compose และการตั้งค่านั้นทำให้คอนเทนเนอร์ bind โฟลเดอร์นั้นได้ ซึ่งทำให้ proxy อ่อนแอลง (ผลที่ตามมา) หากไม่ตั้งค่านี้ ให้อัปเดตด้วย docker compose pull && docker compose up -d เวิร์กเกอร์ยังคงควบคุมทุกคอนเทนเนอร์บนโฮสต์ ดังนั้นเพื่อความปลอดภัยสูงสุด ให้รัน CashPilot บนเครื่องหรือ VLAN เฉพาะ

การเก็บรักษาคีย์ลับ

ข้อมูลรับรองเข้ารหัสด้วย CASHPILOT_ENCRYPTION_KEY ไม่ใช่ CASHPILOT_SECRET_KEY ซึ่งใช้ลงนามเซสชันการเข้าสู่ระบบเท่านั้น คีย์เข้ารหัสสร้างขึ้นอัตโนมัติในการรันครั้งแรกและเก็บไว้ที่ /data/.fernet_key ให้สำรองไฟล์นั้นไว้ หาก volume ถูกสร้างใหม่โดยไม่มีไฟล์นี้ ระบบจะสร้างคีย์ใหม่ และข้อมูลรับรองที่จัดเก็บไว้ทั้งหมดจะอ่านไม่ได้อย่างถาวร การตั้งค่า CASHPILOT_ENCRYPTION_KEY มีไว้สำหรับกู้คืนข้อมูลสำรองนั้น ไฟล์คีย์มีลำดับความสำคัญเหนือกว่าเสมอ การตั้งค่านี้บนระบบที่ทำงานปกติจึงไม่เปลี่ยนอะไร

รหัสผ่านและความลับใน UI

เปลี่ยนรหัสผ่านของตัวเองได้ทุกเมื่อจากเมนูรูปโปรไฟล์ -> Change password (เปลี่ยนรหัสผ่าน) (ใช้ได้ทุกบทบาท) การเปลี่ยนนี้จะออกจากระบบเซสชันอื่นทั้งหมด ใน Settings (การตั้งค่า) ความลับที่จัดเก็บไว้เป็นแบบเขียนได้อย่างเดียว: ใส่ค่าเพื่อเปลี่ยน หรือเว้นช่องว่างไว้เพื่อคงค่าเดิม ข้อมูลรับรองที่บันทึกไว้จะไม่ถูกส่งกลับไปยังเบราว์เซอร์เลย

การอัปเดต CashPilot

ไฟล์ compose ปักหมุดซีรีส์ major.minor เช่น drumsergio/cashpilot:X.Y ดังนั้น pull จะดึงแพตช์ล่าสุดของซีรีส์นั้น:

docker compose pull
docker compose up -d

docker compose pull ดึงอิมเมจล่าสุดที่เผยแพร่ และ up -d สร้างใหม่ เฉพาะคอนเทนเนอร์ที่อิมเมจเปลี่ยน ไฟล์ compose ที่มาพร้อมกันตั้งค่า pull_policy: always ไว้ ดังนั้นแม้แต่ docker compose up -d อย่างเดียวก็จะดึง อิมเมจล่าสุดก่อน

จากแดชบอร์ด Settings (การตั้งค่า), About and updates (เกี่ยวกับและการอัปเดต) รันสองคำสั่งเดียวกันนี้ ให้จากคอนเทนเนอร์ผู้ช่วยที่มีอายุสั้น ผู้ช่วยอ่านไฟล์ compose และ .env ที่อยู่ข้างกัน (หรือไฟล์ที่ส่งด้วย --env-file) ไม่เคยอ่าน shell ที่ใช้เริ่ม CashPilot สมมติว่าเริ่มด้วย CASHPILOT_UI_PORT=8088 docker compose up -d การอัปเดตจะย้ายแดชบอร์ดกลับไปที่ 8080 จึงหยุดและบอกเหตุผลแทน ใส่ค่านั้นไว้ใน .env แล้วปุ่มนี้จะทำงานได้

ไม่ จำเป็นต้อง build ใหม่

CashPilot มีอิมเมจหลายสถาปัตยกรรมที่ build ไว้แล้วบน Docker Hub (drumsergio/cashpilot, drumsergio/cashpilot-worker) docker compose build / --build ใช้เฉพาะเมื่อตั้งใจ build จากซอร์สด้วย docker-compose.build.yml สำหรับการติดตั้งปกติ pull + up -d คือขั้นตอนการอัปเดตที่ครบถ้วนและถูกต้อง

การปักหมุดเวอร์ชันที่ระบุ

หากต้องการอยู่กับรุ่นใดรุ่นหนึ่งโดยเฉพาะ ให้แทนแท็กซีรีส์ X.Y ใน docker-compose.yml ด้วยแท็กรุ่นเต็ม X.Y.Z ทั้งที่ drumsergio/cashpilot และ drumsergio/cashpilot-worker (ใช้แท็กเดียวกันทั้งสองเสมอ) แล้วลบ pull_policy: always ออก ดูแท็กได้ที่ Docker Hub

หากต้องการย้ายไปซีรีส์ที่ใหม่กว่า ให้แก้ทั้งสองแท็ก: ที่โฮสต์ UI ก่อน แล้วจึง ที่โฮสต์เวิร์กเกอร์ทุกเครื่อง อ่าน UPGRADING.md ก่อน เพราะรุ่นหลักอย่าง 3.0 มีขั้นตอนเฉพาะของตัวเอง

การอัปเดตอัตโนมัติ (ไม่บังคับ)

หากต้องการอัปเดตโดยไม่ต้องลงมือเอง ให้ตั้งตัวจัดกำหนดการให้รันสองคำสั่งเดียวกันนี้ เช่น ด้วยรายการ cron รายวัน:

0 4 * * *  cd /path/to/cashpilot && docker compose pull && docker compose up -d

หรือรันตัวอัปเดตอัตโนมัติอย่าง Watchtower หรือ Diun กับคอนเทนเนอร์ของ CashPilot สิ่งเหล่านี้ ไม่บังคับ CashPilot ไม่ได้รวมตัวอัปเดตมาให้

การล้างอิมเมจเก่า

CashPilot ลบอิมเมจเฉพาะหลังจากที่การอัปเดตอิมเมจของแอป มาแทนที่แล้ว และเฉพาะบนเวิร์กเกอร์ที่เข้าถึง Docker socket โดยตรงเท่านั้น นอกเหนือจากนั้น การอัปเดตและการติดตั้งใช้งานใหม่แต่ละครั้ง อาจทิ้งอิมเมจก่อนหน้าไว้บนดิสก์ ในกลุ่มเครื่องทดสอบสามเซิร์ฟเวอร์ อิมเมจเก่าของ CashPilot และแอปหารายได้รวมกันประมาณ 3 GB ซึ่งถือว่าน้อยเมื่อเทียบกับ สิ่งที่โปรแกรมอื่นบนโฮสต์เดียวกันมักทิ้งไว้ ดังนั้นให้ดูทั้งโฮสต์:

docker system df

ค่า RECLAIMABLE ในบรรทัด Images คือพื้นที่ที่ Docker คืนได้

ทำไม CashPilot ไม่ทำส่วนนี้ให้ เวิร์กเกอร์เข้าถึง Docker ผ่าน socket proxy สำหรับอิมเมจ proxy อนุญาตให้ดึงอิมเมจและอ่านอิมเมจตามชื่อ เท่านั้น ไม่สามารถแสดงรายการอิมเมจของโฮสต์หรือลบอิมเมจได้ เวิร์กเกอร์ที่ทำได้ ก็จะเห็นและลบอิมเมจของโปรแกรมอื่นทุกตัวบนโฮสต์ด้วย ดู สิ่งที่ proxy ปฏิเสธ

ขั้นที่ 1: ลบอิมเมจ dangling อิมเมจ dangling คืออิมเมจที่ไม่มีแท็กและไม่มี คอนเทนเนอร์ใดใช้ ทั้งที่กำลังรันและที่หยุดอยู่ การอัปเดตผ่านแท็กที่เปลี่ยนได้อย่าง X.Y (ซีรีส์แบบที่ไฟล์ compose ปักหมุดไว้), latest หรือ digest จะทิ้งอิมเมจแบบนี้ไว้พอดี:

docker image prune

คำสั่งนี้ลบอิมเมจที่รันอยู่ก่อนการอัปเดตผ่านแท็กที่เปลี่ยนได้ด้วย: เมื่อ อิมเมจใหม่ของซีรีส์นั้นมาถึง อิมเมจเก่าก็ไม่มีแท็ก หากต้องการทางย้อนกลับ ให้จด เวอร์ชันที่แน่นอนไว้ก่อนอัปเดต (ส่วนท้ายของแถบด้านข้างแสดงไว้) เพื่อ ดึง drumsergio/cashpilot:<X.Y.Z> ได้อีกครั้ง หรือปักหมุดไฟล์ compose ไว้กับ แท็ก X.Y.Z ที่แน่นอน แล้วอิมเมจเก่าจะยังมีแท็กอยู่ และใช้ขั้นที่ 2 แทน

Docker จะถามก่อนลบ ในรายการ cron ให้เพิ่ม --force เพื่อข้าม คำถาม ตัวเลือกนี้ไม่เปลี่ยนอย่างอื่น:

30 4 * * 0  docker image prune --force

อย่าเพิ่ม -a

docker image prune -a ลบทุกอิมเมจที่ไม่มีคอนเทนเนอร์ใดใช้อยู่ ตอนนี้ ทั้งแบบ dangling และแบบมีแท็ก ซึ่งรวมถึงอิมเมจของ stack ที่ตั้งใจหยุดไว้ และอิมเมจที่ build เองในเครื่องและดึงใหม่ไม่ได้

ขั้นที่ 2: ลบแท็กเก่าที่ปักหมุดไว้ อิมเมจที่ปักหมุดเวอร์ชันไว้จะยังมีแท็ก หลังจากย้ายไปเวอร์ชันใหม่กว่า prune จึงข้ามไป อิมเมจของ CashPilot ต่อไปนี้ ถูกปักหมุด:

ที่เก็บ สิ่งที่ปักหมุด
drumsergio/cashpilot ไฟล์ compose (ซีรีส์เก่า หรือเวอร์ชันที่แน่นอนที่ปักหมุดไว้)
drumsergio/cashpilot-worker ไฟล์ compose เช่นเดียวกับด้านบน
drumsergio/cashpilot-tunnel เวิร์กเกอร์ หนึ่งแท็กต่อเวอร์ชันของเวิร์กเกอร์
drumsergio/cashpilot-earnapp รายการ EarnApp ในแคตตาล็อก
drumsergio/cashpilot-anyone รายการ Anyone Protocol ในแคตตาล็อก

อิมเมจของบริการที่ลบไปแล้วก็เช่นกัน: แท็กจะยังอยู่จนกว่า จะลบเอง อิมเมจในแคตตาล็อกที่ปักหมุดด้วย digest เช่น MystNodes หรือ ProxyBase จะเสียแท็กเมื่ออิมเมจที่ใหม่กว่ามาแทน ขั้นที่ 1 จึงครอบคลุมแล้ว

ก่อนอื่น ให้แสดงรายการแท็กที่ไม่มีคอนเทนเนอร์ใดใช้ ตัวอย่างนี้ใช้กับอิมเมจของเวิร์กเกอร์ สำหรับที่เก็บอื่นในตาราง ให้เปลี่ยน repo:

repo=drumsergio/cashpilot-worker
used=$(docker ps -a --format '{{.Image}}')
docker image ls "$repo" --format '{{.Repository}}:{{.Tag}}' | grep -vxF "$used"

จากนั้นลบแท็กเก่าทีละแท็กตามชื่อ:

docker image rm drumsergio/cashpilot-worker:<old tag>

อย่าเพิ่ม -f หากไม่มีตัวเลือกนี้ Docker จะปฏิเสธการลบอิมเมจที่ คอนเทนเนอร์ยังใช้อยู่ ทั้งที่กำลังรันและที่หยุดอยู่ และพิมพ์ conflict: unable to delete เมื่อเห็นข้อความนี้ ให้เก็บอิมเมจไว้ เก็บแท็ก ที่รันอยู่และแท็กที่รันก่อนหน้านั้นไว้ เพื่อให้ยังย้อนกลับได้หนึ่งเวอร์ชัน ลบเฉพาะแท็กที่เก่ากว่าสองแท็กนั้น

คอลัมน์ Host disk (ดิสก์ของโฮสต์) ในแดชบอร์ดแสดงพื้นที่ว่างบนระบบไฟล์ที่ เก็บ /data ของเวิร์กเกอร์ อิมเมจมักอยู่บนระบบไฟล์เดียวกัน ภายใต้ data root ของ Docker แต่ไม่เสมอไป docker info --format '{{.DockerRootDir}}' แสดง data root ของ Docker หากใช้ containerd image store ซึ่งเป็นค่าเริ่มต้นของ การติดตั้ง Docker Engine 29 ใหม่ อิมเมจจะอยู่ใต้ root ของ containerd แทน ปกติคือ /var/lib/containerd docker info --format '{{.Driver}}' จะพิมพ์ overlayfs สำหรับ containerd image store และ overlay2 สำหรับแบบดั้งเดิม ตรวจสอบพื้นที่ว่างบนระบบไฟล์ที่เก็บไดเรกทอรีที่เกี่ยวข้อง

บริการที่รองรับ

CashPilot รองรับ 60 บริการ ที่เปิดใช้งานอยู่หรืออยู่ในช่วงเบตา ในห้าหมวดหมู่:

  • การแบ่งปันแบนด์วิดท์ (19): แบ่งปันแบนด์วิดท์อินเทอร์เน็ตเพื่อสร้างรายได้แบบพาสซีฟ
  • DePIN (16): เครือข่ายโครงสร้างพื้นฐานทางกายภาพแบบกระจายศูนย์
  • การประมวลผลด้วย GPU (7): ให้เช่า GPU สำหรับงาน AI และงานประมวลผล
  • พื้นที่จัดเก็บ (3): แบ่งปันพื้นที่ดิสก์บนเครือข่ายจัดเก็บข้อมูลแบบกระจายศูนย์
  • การขุด (14): ติดตั้งใช้งานเครื่องขุด หรือติดตามพูลตามที่อยู่รับการจ่ายเงิน (การขุด)

ในจำนวนนี้ 30 บริการติดตั้งใช้งานและจัดการได้โดยอัตโนมัติผ่าน Docker แคตตาล็อกติดตามอีก 30 บริการ (แอปเบราว์เซอร์หรือเดสก์ท็อป 19 รายการ, โหนด GPU 7 รายการ, พูลการขุด 4 รายการ) CashPilot อ่านยอดคงเหลือของบริการเหล่านี้ได้เมื่อมีตัวเก็บข้อมูลรองรับ

ดูแคตตาล็อกทั้งหมดในส่วน คู่มือบริการ

ขั้นตอนถัดไป