How to Setup Minecraft Bedrock Server in Docker

The minecraft bedrock server is still in the alpha stage, but that won’t stop me using it to serve my game with friends and family. The only problem is I have a mac. Naturally docker comes to the rescue. The Linux version of the bedrock server is tested on Ubuntu 18.04. Since 20.04 just came out, why not give it a try? Let’s create a Dockerfile first.

Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
FROM ubuntu:20.04

RUN apt-get update && \
apt-get install -y \
unzip \
curl \
vim \
&& apt-get clean

EXPOSE 19132/udp

WORKDIR /minecraft-server-data

ADD https://minecraft.azureedge.net/bin-linux/bedrock-server-1.14.60.5.zip /minecraft-server-data

RUN unzip bedrock-server-1.14.60.5.zip && \
rm bedrock-server-1.14.60.5.zip && \
chmod +x bedrock_server

CMD LD_LIBRARY_PATH=. ./bedrock_server

VOLUME ["/minecraft-server-data"]

And then build the image and start a container

1
2
3
$docker build --tag bedrock-1.14 .
$docker volume create bedrock-server-1.14-data
$docker run -d -it -p 0.0.0.0:19132:19132/udp --mount source=bedrock-server-1.14-data,target=/minecraft-server-data bedrock-1.14

Notice that when running the container, I have to specify IP to be 0.0.0.0 to listen to all IP addresses for this game to show up in the LAN game. You don’t have to specify that if you just want to connect to a customized server over WAN(For WAN to work, you need to configure your router to forward port 19132 UDP). After the game starts, you can attach to the container to run commands as usual.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
00ac4398cde3 bedrock-1.14 "/bin/sh -c 'LD_LIBR…" 3 minutes ago Up 3 minutes 0.0.0.0:19132->19132/udp confident_neumann
$docker attach 00ac4398cde3
NO LOG FILE! - setting up server logging...
[2020-05-17 21:37:01 INFO] Starting Server
[2020-05-17 21:37:01 INFO] Version 1.14.60.5
[2020-05-17 21:37:01 INFO] Session ID b29e23c6-1a4a-49f0-9310-6344115ef2d4
[2020-05-17 21:37:01 INFO] Level Name: Bedrock level
[2020-05-17 21:37:01 INFO] Game mode: 0 Survival
[2020-05-17 21:37:01 INFO] Difficulty: 2 NORMAL
[2020-05-17 21:37:01 INFO] opening worlds/Bedrock level/db
[2020-05-17 21:37:04 INFO] IPv4 supported, port: 19132
[2020-05-17 21:37:04 INFO] IPv6 not supported
[2020-05-17 21:37:04 INFO] IPv4 supported, port: 39921
[2020-05-17 21:37:04 INFO] IPv6 not supported
[2020-05-17 21:37:05 INFO] Server started.
list
There are 0/10 players online:

To exit the container without killing it, you should not type ctrl+c because it will stop the container. You should type ctrl+p and then ctrl+q to detach from the container. You can customize the detach key by specifying --detach-keys like docker attach --detach-keys "ctrl-a,ctrl-a" 00ac4398cde3, and then you can use your customized detach key in the container.

If you want to directly use the image mentioned above, I have uploaded it to the docker hub. You just need to run following commands

1
2
$docker volume create bedrock-server-1.14-data
$docker run -d -it -p 0.0.0.0:19132:19132/udp --mount source=bedrock-server-1.14-data,target=/minecraft-server-data ycshao/bedrock-1.14

Cheers and happy minecraft!

Reference:
Official Site