Dockerfile
docker-compose.yml
fileTo start off, you'll need a Docker account to run the Minecraft server container. If you don't have one, you can create one for free. Once you have an account, you can download the Docker Desktop application for your operating system.
Once you have Docker Desktop installed, you can run the following command in your terminal to login to your Docker account:
docker login
Next, set up a new directory to store the files for your Minecraft server. The folder will contain the server configuration files, as well as the Docker Compose file to run the server container.
~/
└── minecraft-server/
├── server.properties
├── eula.txt
├── ...
└── Dockerfile
└── docker-compose.yml
Set up the Dockerfile:
FROM
directive specifies the base image for the Minecraft server container.ENV
directive sets the server type to Paper.COPY
directive copies the plugin JAR files to the /plugins/
directory in the container.FROM itzg/minecraft-server
ENV TYPE=PAPER
COPY plugins/*.jar /plugins/
Set up the docker-compose.yml file:
services:
# Minecraft server container
mc:
# Use the itzg/minecraft-server image
image: itzg/minecraft-server
environment:
EULA: "TRUE" # Accept the Minecraft EULA
TYPE: "PAPER" # Set the server type to Paper
MOTD: "My Minecraft Server" # Set the server MOTD
MEMORY: "4G" # Set the server memory to 4GB
stdin_open: true # Enable stdin
tty: true # Enable tty
volumes: # Mount the server data directory
- ./server:/data
restart: on-failure:3 # Restart the container on failure 3 times
ports: # Expose the server port
- "25565:25565"
To run the Minecraft server container, you'll need to build the Docker image and start the container.
docker compose build
docker compose up -d
Once the server is running, you can connect to it using the Minecraft client.
localhost:25565
.