Notes »
Minecraft server with Podman
I’m running a Minecraft server in my LAN for the family to play in the same world.
It should be OK running it from the jar
file, but I decided to use podman because:
- It adds security and “peace of mind” because I’m running it in my personal desktop PC.
- I wanted to try
podman
as root-less alternative to Docker.
Install in Debian
sudo apt install podman crun slirp4netns uidmap fuse-overlayfs
Notes:
- Apparently you can also use the
runc
runtime. - Both
slirp4netns
anduidmap
are “recommended packages”, but they are needed in this case. fuse-overlayfs
is also a “recommended package”, but I have encountered issues with the defaultvfs
storage driver (e.g. stuck onStoring signatures
).
Note: if you started using vfs
–like I did–, you may need to stop your containers and, keeping safe your volumes, remove ~/.local/share/containers/storage
before installing fuse-overlayfs
. Then pull the images again and it should be using overlay
. It is unfortunate that podman
uses the best available driver by default, independently of your existing storage, and they aren’t compatible.
Configure registries
By default podman
on Debian doesn’t come with any registries configured.
mkdir -p $HOME/.config/containers
echo 'unqualified-search-registries=["docker.io", "quay.io"]' > $HOME/.config/containers/registries.conf
From Podman page in Debian’s wiki; although having only docker.io
is probably enough.
Start script
I don’t want to run the container all the time, so this is convenient to start it when needed.
#!/bin/bash
# start the minecraft server
NAME=minecraft-server
VOLUME=$HOME/pods/minecraft/data
podman ps | grep $NAME && exit
TAG=java17-alpine
podman run -d -it --rm -p 25565:25565 -e EULA=TRUE \
--name $NAME \
-v $VOLUME:/data itzg/minecraft-server:$TAG
This expects some directories in place, run:
mkdir -p $HOME/pods/minecraft/data
Tip: save as start
script in $HOME/pods/minecraft/
.
Setup the server
- Start the container and check the logs until it has finished.
- Stop it and edit
server.properties
changing anything you want. - Start the server again.
I’m using itzg/minecraft-server, and these are the docs.
The clients can connect using the IP of the machine running the server (in my case, in my LAN).
Server cheat-sheet
- Start the server: see
start
script - Stop the server:
podman stop minecraft-server
- Check the logs:
podman logs -f minecraft-server
Useful console commands
Disable raids:
podman exec minecraft-server rcon-cli '/gamerule disableRaids true'
Spawn entities:
podman exec minecraft-server rcon-cli '/summon minecraft:chicken x y z'
(get the x y z coordinates from a player by pressing F3 on their client; ensure the player is in an appropriate place!)