docker執行golang可執行檔案最簡docker-compose file

熊先生不开玩笑發表於2024-03-29
version: '3.0'
services:
  server:
    container_name: server
    image: golang:1.22.0
    privileged: true
    restart: always
#    network_mode: host
    ports:
      - 80:80
    volumes:
      - /home/service/server:/home/service/server
      - /home/service/config.yml:/home/service/config.yml
    # 需要指定目錄,不然讀取檔案可能報錯如果程式碼讀取配置不是絕對路徑
    working_dir: /home/service
    command: /home/service/server

相關文章