setupmc.com

Setting up a Minecraft Server on a Hetzner Cloud Server with Docker Compose

In this article, we will show you how to set up a server for Minecraft: Java Edition on a Hetzner Cloud server. We will go through the steps of creating the cloud server, installing Debian, setting up an SSH key, and configuring Docker Compose for easy server management.

Getting Started & Choices
setupmc.com Team

Need a cleaner Java baseline?

Generate a Java Compose setup before you keep patching by hand

If you are still refining the Java server baseline, use the Java configurator and then return to the guides for the next issue.

Open Java configurator

Introduction

Minecraft is one of the most popular games worldwide, and many players want to host their own Minecraft server to play with friends. A self-hosted Minecraft server gives you direct control over software, files, and updates, but it also makes you responsible for security and recovery. Hetzner Cloud is a pragmatic platform for this purpose. This guide builds a reproducible Docker Compose baseline without pretending that the first successful start is the end of server operations.

1. Create a Cloud Server on Hetzner

Sign up on Hetzner

Go to Hetzner Cloud and log in or register. If you register using our link, you will receive $20 / €20 free cloud credit if you have not been a Hetzner customer in the last 12 months. We may receive a commission at no extra cost to you.

Create a Server

Click on New Project in the Hetzner console and enter any name, e.g., “Minecraft”. The project should then appear. Click on Add Server and fill out the form.

Choose a server location as close to you and your friends as possible, e.g., Ashburn for the US East Coast or Hillsboro for the US West Coast. The closer the server location is to the players, the lower the latency (ping) and the smoother the gameplay experience.

Under OS Image, select Debian unless you have experience with another image.

You will learn more about server types and SSH keys in the following sections. Do not leave networking security as an afterthought: attach a Hetzner Cloud Firewall and allow SSH only from your admin IP where practical. Add TCP 25565 only when the server should be reachable by players. The dedicated port 25565 runbook covers the complete path.

Choosing the Right Server Type

Hetzner offers various server types that differ in performance and price. For a Minecraft server, you need a cloud server with sufficient CPU power and RAM, but not necessarily a lot of storage.

The number of CPU cores alone is a poor sizing metric. The main tick loop still benefits heavily from strong single-thread performance, while world generation, networking, plugins, and the JVM also use additional threads. Generally, a cloud server with shared vCPUs is sufficient for a small Minecraft server. However, you can also choose a cloud server with dedicated vCPUs if you need more power.

For a small Vanilla or Paper server, a host with 4 GB RAM is a realistic minimum starting point. Do not assign all of it to Java: Debian, Docker, filesystem caches, and backup jobs need memory too. Modpacks and larger communities commonly need 8 GB or more, but RAM does not compensate for slow CPU cores or expensive plugins.

Recommendation

For a small Vanilla or Paper server, these Arm64 plans can be economical starting points:

  • CAX11 with 2 Arm64 (Ampere) vCPUs and 4 GB RAM
  • CAX21 with 4 Arm64 (Ampere) vCPUs and 8 GB RAM

The itzg/minecraft-server image supports Arm64. However, a modpack or plugin with native libraries may still be x86-64-only. Choose an x86-64 plan if your software stack does not explicitly support Arm64, and benchmark under real player load before committing to a larger server.

2. Set Up an SSH Key

An SSH key is a more secure way to connect to your cloud server than a password. Follow the instructions for your operating system to generate and add an SSH key to Hetzner.

Windows

Open PowerShell and run the following command:

ssh-keygen -t ed25519 -C "hetzner-mc"

Use the default location for the key (C:\Users\YourUser\.ssh\id_ed25519) by pressing ENTER. Optionally, set a password for the key.

Copy the public key to the clipboard. You can view it with the following command:

type C:\Users\YourUser\.ssh\id_ed25519.pub

macOS

Open the terminal and run the following command:

ssh-keygen -t ed25519 -C "hetzner-mc"

Use the default location for the key (~/.ssh/id_ed25519) by pressing ENTER. Optionally, set a password for the key.

Copy the public key to the clipboard. You can view it with the following command:

cat ~/.ssh/id_ed25519.pub

Add Public Key to Hetzner

In the server creation form, click on Add SSH Key and paste the copied SSH key.

3. Connect to the Cloud Server via SSH

After clicking Create & Buy now, the cloud server will be created. You will find your cloud server's IP address in the created project.

Connect to the cloud server via SSH to complete the setup.

Open PowerShell (Windows) or Terminal (macOS) and run the following command:

ssh root@

4. Update Debian and create an admin user

Use the initial root session to update Debian and install sudo:

apt update && apt upgrade -y && apt install -y sudo

Create a separate administrator and copy the authorized SSH key:

adduser mcadmin
usermod -aG sudo mcadmin
install -d -m 700 -o mcadmin -g mcadmin /home/mcadmin/.ssh
cp /root/.ssh/authorized_keys /home/mcadmin/.ssh/authorized_keys
chown mcadmin:mcadmin /home/mcadmin/.ssh/authorized_keys
chmod 600 /home/mcadmin/.ssh/authorized_keys

Open a second terminal and confirm that ssh mcadmin@<IP-Address> works before closing the root session. Use this account for the remaining steps. Disabling root SSH login can be a sensible later hardening step, but only after the new login has been tested successfully.

5. Install Docker and Docker Compose

Run the following commands to install Docker and Docker Compose.

Add Docker GPG Key:

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add Docker Repository:

echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
    $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install Docker and Docker Compose:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Enable Docker, allow the mcadmin account to use the Docker socket, and then reconnect so that the new group membership takes effect:

sudo systemctl enable --now docker
sudo usermod -aG docker mcadmin
exit

Membership in the docker group is effectively root-level access to the host. Add only trusted administrator accounts. After reconnecting, verify both components:

docker --version
docker compose version

6. Setting up the Minecraft Server with Docker Compose

The cloud server is now ready to set up the Minecraft server with Docker Compose.

Create a project directory and navigate to it:

mkdir -p ~/minecraft && cd ~/minecraft

Use the Nano text editor to create a Docker Compose file:

nano compose.yml

After running the command, paste the content of your Docker Compose file for your Minecraft server. To save the file, press CTRL + X, then Y, and confirm with ENTER.

Tip

If you don't have a Docker Compose file for your Minecraft server yet, you can use our Configurator to generate one.

Finally, start the Docker container:

docker compose up -d

Congratulations! Your Minecraft server is now running on a Hetzner Cloud server with Docker Compose.

7. Connecting to Your Minecraft Server

Use your Hetzner server's IP to connect to your Minecraft server.

If joining does not work immediately, do not guess at the network stack. Work through How to Open Port 25565 for a Minecraft Server on Hetzner and Linux instead. That guide checks the full path end to end: Docker port mapping, Linux firewall, and the Hetzner Cloud Firewall.

8. Managing Your Minecraft Server

To manage your Minecraft server, navigate to your project directory:

cd ~/minecraft

Here are some useful commands:

docker compose logs -f
docker compose stop
docker compose start
docker compose down

Next steps

  • If you want a production-ready backup workflow instead of assembling everything yourself, use our Backup Guide.

Stop the Minecraft server:

docker compose stop

Start the Minecraft server:

docker compose start

View Minecraft server logs:

docker compose logs -f

Frequently asked questions

Short answers to the questions that usually come up while working through this topic.