Setting up a Minecraft Server on a Hetzner Cloud Server with Docker Compose
written by Niklas Friedrich Gerstner on January 28, 2025In 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.
This guide also includes specific instructions for Windows and macOS and is suitable for beginners who have never used SSH or Linux commands before.
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 provides better performance and control than a Minecraft server hosting service. Hetzner Cloud is an affordable and powerful solution for this purpose. In this blog post, you will learn how to quickly and easily set up a Minecraft server on a Hetzner Cloud server using Docker Compose.
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. All other settings can be left at their default values.
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 plays a minor role in a Minecraft server. A cloud server with a powerful core is better than one with many weak cores. This is because Minecraft mainly runs on a single core and has limited multithreading support. 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 Minecraft server with 2-3 players and no mods, 2-3 GB RAM is sufficient. For a larger server with more players or mods, 4 GB or more is recommended. Keep in mind that the operating system also requires RAM, so choose a cloud server with at least 4 GB RAM.
Recommendation
For beginners, the following server types are recommended:
- CAX11 with 2 Arm64 (Ampere) vCPUs and 4 GB RAM
- CAX21 with 4 Arm64 (Ampere) vCPUs and 8 GB RAM
These server types offer better price-performance ratios than Intel/AMD server types and are well-suited for Minecraft: Java Edition servers.
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 the Operating System and Dependencies
The operating system and some dependencies on your cloud server may not be up to date. Execute the following command to update them:
apt update && apt upgrade -y
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
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 you encounter issues, ensure that port 25565 is open in the Hetzner firewall settings.
8. Managing Your Minecraft Server
To manage your Minecraft server, navigate to your project directory:
cd ~/minecraft
Here are some useful commands:
Stop the Minecraft server:
docker compose stop
Start the Minecraft server:
docker compose start
View Minecraft server logs:
docker compose logs -f