Deploying a Minecraft Server Using Docker on My Dev Server

1. Create Your Server

You'll need a cloud server to host minecraft, and we've got the simplest cloud server platform anywhere!

Click the link below to create your server on our platform:

Note: This button will redirect you to the home page to create your server. After creating your server, return to this guide and continue with the next step.

2. Connect to Your Server

Now that your server is up and running, let's connect to it using SSH. You created an SSH key during server creation and saved it. You will use this key to connect to your server.

We have provided an example SSH command that you can use. It is under "Access" on the home page for your server.

Click on the command (it is automatically copied).

Open a Powershell window and paste in the command. If you stored the SSH key file in a folder, you will have to add that to the command.

You can also just type in the command as follows:

ssh -i [path_to_ssh_file] root@[ip_address]

Replace the following:

  • [path_to_ssh_file]: The complete path to your SSH key file.
  • [ip_address]: The IP address of your newly created server.

Step 3: Update and Install Docker

  1. Update your package manager:
    sudo apt update
    
  2. Install Docker:
    sudo apt install docker.io
    
  3. Enable and start the Docker service:
    sudo systemctl enable docker
    sudo systemctl start docker
    
  4. Verify the installation:
    docker --version
    

Step 4: Set Up a Directory for Minecraft Data

  1. Create a directory on your server for the Minecraft server data:
    mkdir -p ~/minecraft-data
    
  2. Adjust permissions for the directory:
    sudo chmod -R 755 ~/minecraft-data
    

Step 5: Run a Minecraft Server Docker Container

  1. Pull the latest itzg/minecraft-server image from Docker Hub:

    sudo docker pull itzg/minecraft-server
    
  2. Run the Minecraft server using the following command, ensuring it will restart unless stopped:

    sudo docker run -d -p 25565:25565 -v ~/minecraft-data:/data -e EULA=TRUE --restart unless-stopped --name minecraft-server itzg/minecraft-server
    

    Here’s a breakdown of the flags used:

    • -d: Runs the container in detached mode (in the background).
    • -p 25565:25565: Maps port 25565 on the server to port 25565 in the container, allowing access to the Minecraft server.
    • -v ~/minecraft-data:/data: Mounts your server’s ~/minecraft-data directory as the container’s /data directory, preserving game data.
    • -e EULA=TRUE: Accepts the Minecraft EULA.
    • --restart unless-stopped: Ensures the container will automatically restart if the server reboots or if the container stops unexpectedly.
  3. Check that your Minecraft server is running by listing active Docker containers:

    sudo docker ps
    

Step 6: Connect to Your Minecraft Server

  1. Open the Minecraft game on your local computer.
  2. In the Multiplayer section, add a new server with the IP address of your My Dev Server machine.
  3. You should be able to join the server now!

Step 7: Managing Your Server

To manage your server, you can shut it down and restart it whenever you need it. The Minecraft Docker container will restart automatically on startup due to the --restart unless-stopped option set earlier.


Your Minecraft server is now set up for consistent uptime and automatic restart on reboot! Enjoy your gaming experience!

Logo

© Copyright 2024. Make Life Great LLC. All rights reserved.

FacebookFeedTwitter