itzg / docker-mc-backup

Provides a side-car container to backup itzg/minecraft-server world data
https://hub.docker.com/r/itzg/mc-backup
MIT License
298 stars 51 forks source link

Incompatability with Lazytainer #181

Closed Player505 closed 2 months ago

Player505 commented 2 months ago

I'm trying to set up a docker compose that both does backups and sleeps the minecraft container when no traffic is online. However, this doesn't appear to work. Bellow is my compose files and the console error that I get.

I'm assuming the issue is with the network mode on the minecraft container being service:lazytainer since the console error is about not being able to find the host. But when I add the same network mode to the backup container the issue persists.

version: '3.8'

services:
  lazytainer:
    image: ghcr.io/vmorganp/lazytainer:master
    environment:
      VERBOSE: false
    ports:
      - 25565:25565
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    labels:
      - lazytainer.group.minecraft.sleepMethod=stop
      - lazytainer.group.minecraft.ports=25565
      - lazytainer.group.minecraft.minPacketThreshold=2
      - lazytainer.group.minecraft.inactiveTimeout=600
    restart: unless-stopped
    network_mode: bridge
  mc:
    image: itzg/minecraft-server
    environment:
      EULA: TRUE
      TYPE: PAPER
      MEMORY: 4G
      VERSION: "1.20.1"
    volumes:
      - mc:/data
    labels:
      - lazytainer.group=minecraft
    depends_on:
      - lazytainer
    network_mode: service:lazytainer
    tty: true
    stdin_open: true
    restart: unless-stopped
  backups:
    image: itzg/mc-backup
    environment:
      BACKUP_INTERVAL: "2h"
      RCON_HOST: mc
      INITIAL_DELAY: 0
    volumes:
      - mc:/data:ro
      - ./mc-backups:/backups

volumes:
  mc: {}
backups-1     | 2024-05-20T06:42:32+0000 ERROR Unable to execute rcon-cli save-on - try 0/5. Retrying in 10s
backups-1     | 2024-05-20T06:42:32+0000 ERROR Failure reason: 2024/05/20 06:42:32 Failed to connect to RCON serverdial tcp: lookup mc on 127.0.0.11:53: no such host   
itzg commented 2 months ago

Yes, I believe you're right. I'm thinking put backup service on the same network mode and set RCON_HOST to localhost.

Player505 commented 2 months ago

Yes that worked. I got an authentication error since I forgot to set the RCON password on both the minecraft and backup container but once I did that it worked well. Here is my docker compose if you are interested.

version: '3.8'

services:
  lazytainer:
    image: ghcr.io/vmorganp/lazytainer:master
    environment:
      VERBOSE: false
    ports:
      - 25565:25565
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    labels:
      - lazytainer.group.minecraft.sleepMethod=stop
      - lazytainer.group.minecraft.ports=25565
      - lazytainer.group.minecraft.minPacketThreshold=2
      - lazytainer.group.minecraft.inactiveTimeout=600
    restart: unless-stopped
    network_mode: bridge
  mc:
    image: itzg/minecraft-server
    environment:
      EULA: TRUE
      TYPE: PAPER
      MEMORY: 4G
      VERSION: "1.20.1"
      RCON_PASSWORD: minecraft
    volumes:
      - mc:/data
    labels:
      - lazytainer.group=minecraft
    depends_on:
      - lazytainer
    network_mode: service:lazytainer
    tty: true
    stdin_open: true
    restart: unless-stopped
  backups:
    image: itzg/mc-backup
    network_mode: service:lazytainer
    environment:
      BACKUP_INTERVAL: "2h"
      INITIAL_DELAY: 0
      RCON_HOST: localhost
      RCON_PASSWORD: minecraft
    volumes:
      - mc:/data:ro
      - ./mc-backups:/backups

volumes:
  mc: {}