setupmc.com

Set up a Minecraft server on Hetzner with Docker Compose

Set up a Java server on Hetzner Cloud: Debian, SSH access, Docker Compose, and the first server start.

Getting Started & Choices
setupmc.com Team

Prerequisites

You need a Hetzner Cloud account and SSH access. You manage the server yourself and are responsible for updates and backups.

1. Create a Cloud Server on Hetzner

Sign up on Hetzner

Log in to the Hetzner Console or create an account.

As of October 4, 2026, Hetzner offers €50 starting credit for new customers. Get the current code from the official promotion page. Redeem it within 14 days of registration under User Account → Promo Codes. The credit expires at the end of the calendar month in which you redeem it.

Create a Server

Click on New Project in the Hetzner console and enter any name, e.g., “Minecraft”. 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.

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

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

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 / Linux

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

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.

Start the container:

docker compose up -d

Check the container logs to confirm that the Minecraft server has finished starting.

7. Connecting to Your Minecraft Server

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

If you cannot connect, follow How to Open Port 25565 for a Minecraft Server on Hetzner and Linux. 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
TaskCommand
Follow logsdocker compose logs -f
Stop the serverdocker compose stop
Start a stopped serverdocker compose start

Next steps

Java configurator

Create a Compose file

Choose your server software, version, and settings, then download your configuration.

Open Java configurator

Frequently asked questions