Search code examples
dockerdocker-compose

How do I fix an Error with docker compose up


Im currently try to setup Pterodactyl

this im my 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: "[email protected]"

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: "[email protected]" #MAIL_DRIVER: "smtp" #MAIL_HOST: "smtp.gmail.com" #MAIL_PORT: "587" #MAIL_USERNAME: "[email protected]" #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 `

now im trying to run docker-compose up an get this error:

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 serviceskey, or omit theversion 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/

How can I solve this problem?


Solution

  • You are using a very old version of the Compose tool. The only supported version for the past year or so ignores the version: line; version: "3.8" was supported starting in Compose 1.25.5, from February of 2020.

    The current (2.x) version of Compose runs as a Docker CLI plugin. The Docker documentation has instructions for installing it.

    If you have both versions of Compose available, you may need to make sure you run docker compose with a space, and not docker-compose with a hyphen.

    You may be able to just change the version: line to something older. The Compose file format hasn't changed that much, and it's very possible that declaring version: "3.0" will work as well. Note that this is a very complicated Compose file, that uses some obsolete features (links:), has some unnecessary settings (networks:), and grants itself unrestricted administrator-level access to the entire host system (by bind-mounting the Docker socket), and simplifying the Compose file might help work around any version-related issues.