Skip to content

Instantly share code, notes, and snippets.

@armandosg
Last active August 28, 2024 06:13
Show Gist options
  • Save armandosg/c785d8f4b6ae874d4aaec3fa8f8de03e to your computer and use it in GitHub Desktop.
Save armandosg/c785d8f4b6ae874d4aaec3fa8f8de03e to your computer and use it in GitHub Desktop.
Create a Minecraft Server: the easiest way πŸš€

How to create a Minecraft server and not die trying πŸš€

Introduction

This guide will guide you through the configuration of a Minecraft Server using Docker, a technology that will hand almost all the server configuration.

Pre-requisites

The only thing that you need before getting started is a non-user account with administrative privileges (sudo access).

If already have one you can skip this section.

su -
adduser your_username
usermod -aG sudo your_username
su - your_username

Installing Docker

Before we install anything first update the apt packages.

sudo apt-get update

Then install some packages that will let us install Docker over HTTPS.

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Now that we have the necessary packages we proceed to download the GPG key for docker and add it to the apt sources.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update

And finally we install docker

sudo apt install docker-ce

Minecraft Server setup

We only need three commands to get our server up and running on our Ubuntu machine.

The first command will pull the docker image. This docker image already includes all the instructions to setup the server, so we won't have to deal with all the server configuration.

sudo docker pull sirplexus/minecraft-server-standalone:latest

After pulling the image we execute the command that will create and configure our docker container.

sudo docker container create --publish your_public_ip_address:25565:25565/tcp --name "My-Minecraft-Server" --env RAM=2G sirplexus/minecraft-server-standalone

Finally we run the server with this command.

sudo docker container start My-Minecraft-Server

Also to stop the server anytime you want, run this command.

sudo docker stop My-Minecraft-Server

Opening firewall ports

The final step is to open the port that your clients will need to access.

sudo ufw allow 25565/tcp

Additionally, you might have to tell your internet provider you need to open that port. This is just in case that the machine your are running this server from is on your home network.

If you will run this from a cloud service solution like DigitalOcean or Google Cloud Platform then opening the port using the command above may be enough.

Accesing the server from Minecraft

To access the server, just add the server address from the game menu and put whatever name you like.

your_public_ip_address:25565
@johsjohsjohs
Copy link

dockers are stupid. you shuld just use the god tham binnary stop making stuff more complicated than it needs to be. follow the unix filosofty

@DaeliCode
Copy link

@johsjohsjohs, How is Docker "more complicated" than the "classic way"?

Classic way: Install Java/OpenJDK, Download Minecraft Server jar, Start Server (And you still have to setup your init system to launch it at boot)
Docker way: Install Docker, Pull image, Start, End

I understand the Unix philosophy, but that didn't stop Linux distro from accepting systemd.
Don't worry I know the difference between Linux and Unix, I'm just saying that not everything follow the Unix philosophy.
(And (for the moment) Docker can't be installed on Unix systems)

Also, nobody force you to use Docker to run a Minecraft server, and you can find a lot of tutorials on how to setup without it.

Btw, I use arch.

@johsjohsjohs
Copy link

btw i also use arch @DaeliCode local is better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment