You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署Pterodactyl时docker-compose up版本不支持报错的解决方法

问题:Docker Compose版本不兼容导致Pterodactyl面板启动失败

我尝试搭建Pterodactyl面板,使用以下docker-compose.yml配置文件:

version: "3.8"

# This section declares the basic config of all of your Containers that are
# declared below as "services"
x-common:
  database:
    &db-environment
    # You don't need to change these because it will not be exposed to the public.
    MYSQL_PASSWORD: &db-password "CHANGE_ME"
    MYSQL_ROOT_PASSWORD: "CHANGE_ME_TOO"
  panel:
    &panel-environment
    #This is the URL that your panel will be on after being reverse proxied.
    # set this to "https://yoursubdomain.yourdomain.yourdomainstld"
    APP_URL: "https://subdomain.domain.tld"
    # A list of valid timezones can be found here:
    # http://php.net/manual/en/timezones.php
    APP_TIMEZONE: "America/New_York"
    APP_SERVICE_AUTHOR: "youremail@gmail.com"

# Mail is an optional Setup, I have the basic setup if you want to use a gmail
# account. You will need an App Password as the MAIL_PASSWORD field, not your
# gmail password. Uncomment the following lines to enable mail.
#mail:
#&mail-environment
#MAIL_FROM: "youremail@gmail.com"
#MAIL_DRIVER: "smtp"
#MAIL_HOST: "smtp.gmail.com"
#MAIL_PORT: "587"
#MAIL_USERNAME: "youremail@gmail.com"
#MAIL_PASSWORD: ""
#MAIL_ENCRYPTION: "true"
services:

# Wings is the service that hooks into docker and actually creates your game
# servers,
  wings:
    image: ghcr.io/pterodactyl/wings:latest
    restart: always
    networks:
      - ptero0
    # These are the ports exposed by Wings, I don't recommend changing them.
    ports:
      - "8443:443"
      - "2022:2022"
    tty: true
    environment:
      TZ: "America/New_York"
      # For ease of setup, this is going to use root user.
      WINGS_UID: 0
      WINGS_GID: 0
      WINGS_USERNAME: root
    # This is where docker will bind certain parts of container to your actual
    # host OS. These locations will be used later.
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock" # DO NOT CHANGE
      - "/var/lib/docker/containers:/var/lib/docker/containers" # DO NOT CHANGE
      - "/opt/pterodactyl/wings/config:/etc/pterodactyl" # Feel free to change.
      - "/var/lib/pterodactyl:/var/lib/pterodactyl" # DO NOT CHANGE
      - "/var/log/pterodactyl:/var/log/pterodactyl" # DO NOT CHANGE
      - "/tmp/pterodactyl/:/tmp/pterodactyl/" # Recommended not to change.

# It's a database. Not much else to explain.
  database:
    image: mariadb:10.5
    restart: always
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - "/opt/pterodactyl/panel/database:/var/lib/mysql"
    environment:
      <<: *db-environment
      MYSQL_DATABASE: "panel"
      MYSQL_USER: "pterodactyl"

# It's a CACHE database. Not much else to explain.
  cache:
    image: redis:alpine
    restart: always

# Now the fun part. Your actual panel.
  panel:
    image: ghcr.io/pterodactyl/panel:latest
    restart: always
    # For NGINX Reverse Proxy, I will be using these ports for simplicity.
    ports:
      - "802:80"
      - "4432:443"
    # Links these containers together in a docker network.
    links:
      - database
      - cache
    # This is where docker will bind certain parts of container to your actual
    # host OS. These don't really matter that much.
    volumes:
      - "/opt/pterodactyl/panel/appvar/:/app/var/"
      - "/opt/pterodactyl/panel/nginx/:/etc/nginx/http.d/"
      - "/opt/pterodactyl/panel/logs/:/app/storage/logs"
    # Sets the config stuff
    environment:
      <<: [*panel-environment]
      # <<: [*mail-environment]
      DB_PASSWORD: *db-password
      APP_ENV: "production"
      APP_ENVIRONMENT_ONLY: "false"
      CACHE_DRIVER: "redis"
      SESSION_DRIVER: "redis"
      QUEUE_DRIVER: "redis"
      REDIS_HOST: "cache"
      DB_HOST: "database"
      DB_PORT: "3306"

# This is Wings' Network. We don't need much depth here, all you need to know, is
# that it allows the passthrough of the ports from Wings.
networks:
  ptero0:
    name: ptero0
    driver: bridge
    ipam:
      config:
        - subnet: "192.55.0.0/16"
    driver_opts:
      com.docker.network.bridge.name: ptero0

执行docker-compose up时出现以下错误:

ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

解决方案

这个错误是因为当前安装的Docker Compose版本过旧,不支持3.8版本的Compose文件格式,有两种解决方式:

方式一:升级Docker Compose到兼容版本

如果是Linux系统,执行以下命令升级到最新版:

# 卸载旧版docker-compose
sudo apt remove docker-compose -y
# 下载最新版docker-compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 赋予执行权限
sudo chmod +x /usr/local/bin/docker-compose

执行docker-compose --version验证版本,确保版本号在v1.29.0以上(该版本开始支持3.8格式),或者直接安装v2.x版本的Docker Compose。

如果是使用Docker Desktop的用户,直接升级Docker Desktop即可自动更新内置的Compose版本。

方式二:修改Compose文件的版本号为当前支持的版本

打开docker-compose.yml文件,将第一行的version: "3.8"修改为当前Compose版本支持的格式:

  • 若当前Compose版本是v1.27.0+,可改为version: "3.3"
  • 若当前Compose版本更旧,可改为version: "2.4"

配置中使用的x-common扩展字段在2.4及以上版本中都支持,修改版本号后无需调整其他配置即可正常运行。


内容的提问来源于stack exchange,提问作者stormyark

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 16:49:51