Skip to content

[Question] How to use in Portainer Stack #90

Description

@GudBoiNero

Hey I seriously love the Minecraft server docker container, I've used it a bunch, but I do always run into the same issue where I have to manually stop the server whenever I want to redeploy or test it, hence why I want to use this.

However here's the thing, I'm doing this all within Portainer, and I'm quite a beginner with Docker so I'm confused as to how I could implement this mc-server-runner with my Portainer stack.

Here is my current stack-

services:
  mc:
    container_name: rlcraft_dregora
    image: itzg/minecraft-server:java8
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    restart: no      # Prevent auto-start
    ports:
      - "43300:25565"
    environment:
      EULA: "TRUE"
      MEMORY: 12G
      TYPE: AUTO_CURSEFORGE
      DEBUG: "true"
      VERSION: 1.12.2
      CF_PAGE_URL: "https://www.curseforge.com/minecraft/modpacks/rlcraft-dregora/files/5861566"
    volumes:
      - mc_forge:/data
      - ./mods:/mods:ro
  
  scheduler:
    image: ubuntu:latest
    container_name: minecraft_scheduler
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # Allow scheduler to control Docker
    command: >
      bash -c "
      apt-get update &&
      apt-get install -y cron docker.io &&
      echo '0 0 * * 6 docker start rlcraft_dregora' > /etc/cron.d/minecraft-scheduler &&
      echo '0 0 * * 1 docker stop rlcraft_dregora' >> /etc/cron.d/minecraft-scheduler &&
      chmod 0644 /etc/cron.d/minecraft-scheduler &&
      crontab /etc/cron.d/minecraft-scheduler &&
      cron -f"
    restart: unless-stopped

volumes:
  # declared the named volume, but use default/local storage engine
  mc_forge: {}

I've got a fun little use case where I'm using a cron job to allow the server only to run while it's a weekend! It works, well, if you ignore the fact that I can't actually stop the server to begin with.

So I stumbled across this repository and figured it would be exactly what I needed!

I'm just a little stumbled as to how exactly I should implement this into my stack. I would prefer if it was something I could do in the stack file, but I figure that would make things more complicated, I would just like some help figuring out possible ways to use the wrapper for this server.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions