Skip to content

Instantly share code, notes, and snippets.

@yechentide
Last active March 27, 2023 03:04
Show Gist options
  • Save yechentide/466e4b2cccca74baeb37e488aebb198e to your computer and use it in GitHub Desktop.
Save yechentide/466e4b2cccca74baeb37e488aebb198e to your computer and use it in GitHub Desktop.

Start a docker container

docker run -it --name mc \
  -e TZ=Asia/Tokyo \
  -p 19132:19132/udp \
  -v ~/mc-server:/root/server \
  -v ~/mc-worlds:/root/worlds \
  debian:11-slim /bin/bash
version: "3.0"

services:
  mc:
    image: debian:11-slim
    container_name: mc
    hostname: mc-host
    ports:
      - 19132:19132/udp
    volumes:
      - /home/tide/servers/mc:/root/server
      - /home/tide/worlds/mc:/root/worlds
      - /home/tide/servers/mc-conf:/root/config
    environment:
      - TZ=Asia/Tokyo
    tty: true

Install bds

apt update
apt install -y curl unzip tmux wget

url='https://minecraft.fandom.com/wiki/Bedrock_Dedicated_Server'
bds_version=$(curl -s "$url" | grep '<th rowspan="1" colspan="5">' | tail -n 1 | sed 's/[<>]/\n/g' | grep -E '^[1-9]' | head -n 1)
bds_zip="bedrock-server-${bds_version}.zip"

mkdir /root/server
curl -o "/root/server/${bds_zip}" "https://minecraft.azureedge.net/bin-linux/${bds_zip}"
unzip -q -d /root/server "/root/server/${bds_zip}"
rm /root/server/allowlist.json /root/server/permissions.json /root/server/server.properties

ln -s ~/worlds/ worlds
ln -s /root/config/allowlist.json allowlist.json
ln -s /root/config/permissions.json permissions.json
ln -s /root/config/server.properties server.properties

Run BDS

tmux -u new -d -s 'main' 'cd /root/server; LD_LIBRARY_PATH=. ./bedrock_server'

Change game rules

gamerule showCoordinates true
gamerule pvp false
gamerule tntExplodes false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment