Hello, everyone! How are you today? I'm going to explain about setup Minecraft Server on AWS EC2. We will use Docker to run the Minecraft Server to minimize the setup of our AWS EC2. Let's go!
Prepare SSH Client
- For Windows, you may use putty or another SSH client.
- For Ubuntu, you can check this article on how to install it
Prepare AWS EC2
-
Visit EC2 page. Make sure you are visiting the correct region.
-
Click on Instances. After that, click Launch Instances.
-
Fill in the EC2 name. After that, please make sure the number of instances is 1. Finally, choose Ubuntu as the OS. Note: You may choose another OS. But, you will need to find how to set up Docker for your selected OS.
-
Select instance type. I'm using
t3.small
since I will not have many users on my own server. Feel free to choose another instance type. But, I will recommend usingt3.small
as a minimum specification. Choose your key pair. If you don't have it yet, you may create new
key pair
usingCreate new key pair
link. You will need this to SSH into your server.-
Now, we will set up the network. Please click Edit on the Network Setting section. After that, choose the subnet as you wish. I select
ap-southeast-3c
. I disable Auto-assign public IP since I will use Elastic IP. -
We will create a new security group. Make sure you've selected
Create security group
. Update the Security group name with an appropriate name, for example,minecraft-server-security-group
, etc. ClickAdd security group rule
, and fill in the Port range forSecurity group rule 2
with 25565. Port 25565 will be used to host the Minecraft server. Click on the source, and make sure you choose0.0.0.0/0
. -
Please fill in your desired volume size in Configure volume section. I use 25 GiB.
-
Click
Launch instance
in the summary section.
Setup the Elastic IP
-
Go to the VPC page, and select Elastic IPs. After that click the
Allocate Elastic IP address
button. -
I use default options, and click
Allocate
. -
You will get the notification message, and click the
Associate this Elastic IP address
button. -
Select the instance you've created before. After that, click Associate button.
SSH to our EC2 using Public IP
-
Make sure you can SSH to our previous EC2.
-
Update our package reference using
sudo apt update
. Install docker. You might want to read this article on how to install the docker. Note: Since I want to use docker without
sudo
for myubuntu
user, you might want to read this. Make sure you are re-login after setup that.-
Check your docker installation. I use
docker ps
.
Run Minecraft Server
We will use this docker image.
-
We will use
docker compose
too. So, prepare thedocker-compose.yml
and host theyml
onminecraft
directory. I use this configuration. Note: If you want to know more the environment values to customize your server, please visit this.
version: "3" services: mc: image: itzg/minecraft-server:java17-alpine ports: - 25565:25565 environment: EULA: "TRUE" tty: true stdin_open: true restart: unless-stopped volumes: # attach a directory relative to the directory containing this compose file - ./minecraft-data:/data
Start our server!
docker compose up -d
.-
To monitor the process, you may use
docker compose logs -f
. To quit the logs monitor, useCTRL+C
.
Let's Play!
Please use your Minecraft Client application.
-
Input your EC2 IP address and port into your Minecraft Client application. Enjoy your server!
Additional
- If you need to auto-start and auto-stop your EC2 instance. Please check this article.
- If you want to explore another alternative. I think you may try another Amazon Machine Image (AMI).
Thank you
Thanks for reading! If you have feedback, feel free to comment on this post.
Top comments (4)
Hey mate ,
I have never played Minecraft before ,
Is there a free version available that I can connect to my ec2 instance and test that the server is working fine .
Your article has was the only article simple and clear I faced some issues while downloading docker compose but troubleshooted it already.
Thanks
I think you want to find the Minecraft client, right? I will not share specific client apps because it might violate the legal. π You can check here the alternative Minecraft client.
whatifgaming.com/best-minecraft-la...
your tutorial can be done using aws free tier?
I think it will have some issues, especially with the performance. You will need to set the memory limit to ensure no more than 2 GB. However, you may get "laggy" after some exploration/building.
As an alternative, you may need to get rid of the docker and run the server using Java directly.