docker-minecraft-bedrock-server icon indicating copy to clipboard operation
docker-minecraft-bedrock-server copied to clipboard

Update automatically

Open joshuaganger opened this issue 2 years ago • 7 comments

Would it be possible for this to update automatically? I understand that I can restart the container and it will pull the latest bedrock server version, but I'm not sure how to know when updates are released. Right now it feels like I have to wait until clients are unable to connect before I'll know. This isn't ideal because I may not be immediately available when the issue arises. Thoughts?

joshuaganger avatar Apr 20 '22 14:04 joshuaganger

That's a fair request; however, it's a non-trivial problem to solve since it would need to coordinate the restart of the server to avoid disrupting players. It also needs the involvement of a background process to check for updates. The container already wraps the server in https://github.com/itzg/entrypoint-demoter ; however, that tool is so far agnostic to the actual process running.

itzg avatar Apr 20 '22 17:04 itzg

Although not ideal, you could use Watchtower to automate updating your server containers. You would need to be careful to schedule Watchtower to run after a backup runs, so you have a known-good copy if there are any issues.

nomad64 avatar Apr 28 '22 16:04 nomad64

I believe the container image pulls the latest version of the bedrock server at startup. Updates to the bedrock server don’t necessarily correlate with updates to the docker container though. I’m not suer the Watchtower approach would work in this context.

Joshua Ganger Systems Engineer III Cornell Lab of Ornithology

From: Jon @.> Sent: Thursday, April 28, 2022 12:35 PM To: itzg/docker-minecraft-bedrock-server @.> Cc: Joshua Jon Ganger @.>; Author @.> Subject: Re: [itzg/docker-minecraft-bedrock-server] Update automatically (Issue #233)

Although not ideal, you could use Watchtower to automate updating your server containers. You would need to be careful to schedule Watchtower to run after a backup runs, so you have a known-good copy if there are any issues.

— Reply to this email directly, view it on GitHubhttps://github.com/itzg/docker-minecraft-bedrock-server/issues/233#issuecomment-1112420842, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALNF3RHNUVDZW6KVFB7MHW3VHK45BANCNFSM5T4FASSA. You are receiving this because you authored the thread.Message ID: @.***>

joshuaganger avatar Apr 28 '22 17:04 joshuaganger

@joshuaganger is right. Instead, something would need to watch the download page like https://github.com/itzg/docker-minecraft-bedrock-server/blob/master/bedrock-entry.sh does and notice when the referenced download URL changes.

itzg avatar Apr 28 '22 19:04 itzg

So I wrote this whole thing about Watchtower scopes and schedules, then realized I was being silly because that doesn't solve anything. Sorry for the spam. :(

I think the "best" way to somewhat-automate updates is to just restart the containers on a schedule. Assuming you use a standardized name for your containers, this can be done by another container using the following docker-compose:

version: '3.7'
services:
  restart_agent:
    image: alpinelinux/docker-cli
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    command: docker container restart -t 30 $(docker ps --filter name=mc_bedrock_srv* --quiet)
    deploy:
      restart_policy:
        delay: 24h

The name= variable accepts regular expressions. In my case, all of my server containers are prefixed with mc_bedrock_srv, so it is an easy glob.

Note that this runs on a loosely-defined schedule that will shift, which is not ideal. Alternatively, just scheduling a cronjob to run docker container restart -t 30 $(docker ps --filter name=mc_bedrock_srv* --quiet) may work better.

nomad64 avatar Apr 29 '22 14:04 nomad64

Hi, is restarting the docker always enough? I am still not clear on when to restart and when to pull a new image. any hint appreciated

Rello avatar Feb 13 '23 12:02 Rello

@Rello the Minecraft version is checked at (and only at) startup, so restarting the container is all that is needed in most cases.

It doesn't hurt to pull the image every time since docker will skip layers already available. In general though, it's only if the startup automation was changed that an image needs to be pulled.

itzg avatar Feb 13 '23 13:02 itzg