Setting Up a Minecraft Server with Docker on AWS Linux Terminal

Setting Up a Minecraft Server with Docker on AWS Linux Terminal

Here's how you can create a Minecraft server using Docker on an AWS Linux terminal:

Prerequisites:

  • An AWS account with an EC2 instance running Amazon Linux 2 or similar.
  • Basic knowledge of Linux commands and Docker.
  • A Minecraft server jar file (download from the official website or a trusted source).

Steps:

Connect to your EC2 Instance: Use SSH to connect to your EC2 instance using its public IP address or a bastion host.

Install Docker:

  • Run the following commands to update package lists and install Docker:

sudo yum update -y
sudo amazon-linux-extras install docker        

  • Start the Docker service:

sudo service docker start        

  • Verify Docker installation:

docker ps        

Create a Docker User and Group:

  • Create a dedicated user and group for running Docker:

sudo useradd -r minecraft 
sudo groupadd -r minecraft        

  • Add the ec2-user to the minecraft group:

sudo usermod -a -G minecraft ec2-user        

Create a Directory for the Minecraft Server:

  • Create a directory for your server files:

mkdir minecraft-server
cd minecraft-server        

Download the Minecraft Server Jar File:

Download the desired Minecraft server jar file into the minecraft-server directory.

Create a docker-compose.yml file:

  • Create a file named docker-compose.yml with the following content:

version: "3.8"

services:
  minecraft-server:
    image: minecraft:latest
    restart: unless-stopped
    environment:
      EULA: TRUE
      SERVER_NAME: "your-server-name"
      # Optional: Specify world name, difficulty, etc.
    ports:
      - "25565:25565"
    volumes:
      - ./world:/data
    user: minecraft:minecraft        

Replace "your-server-name" with your desired server name.Uncomment and customize any optional environment variables.

Start the Minecraft Server:

  • Run the following command to start the server:

docker-compose up -d        

This will download the Minecraft image, create and run a container, and map port 25565 on your server to port 25565 on the container.


  • Connect to your Minecraft Server: Use your EC2 instance's public IP address or domain name and port 25565 to connect to the server from your Minecraft client.


Additional Notes:

  • You can customize the server configuration by editing the server.properties file within the container (mounted volume).
  • Consider using persistent storage for the world directory (/data) to avoid losing data when restarting the container.
  • Secure your server by setting strong passwords and limiting access to port 25565.

Remember to adjust these steps based on your specific needs and environment. Enjoy your Minecraft server!


Deepak Maurya

Geek |Tech Enthusiast | Creator | Entrepreneur | Technologist | Innovator | Multi Tech Patent Holder | Founder of Dossmediatech & Poketship

1 年

Nice

回复

要查看或添加评论,请登录

Lakshya Gupta的更多文章

其他会员也浏览了