Today, I am going to show you how to set up a docker minecraft server on Ubuntu. I use itzg/docker-minecraft-server for all my servers as, when paired with docker compose, it provides a fast, easy way to deploy new servers.
Step 1 — Install Docker and Docker Compose:
Update packages and install docker: Open a terminal and run the following command:
sudo apt-get update
sudo apt install docker docker-compose
Add your user to the docker group: This allows you to run Docker commands without using sudo:
sudo usermod -aG docker $USER
Verify installations: Check if Docker and Docker Compose are installed correctly by running the following commands:
You should see the version numbers of Docker and Docker Compose, indicating that they are successfully installed.
If so, then that's it! You have now installed Docker and Docker Compose on Ubuntu.
Step 2 — Configure the config
Now copy the following code into a file called
docker-compose.yamlor run the following command to download the file from my GitHub:
curl -O "https://gist.githubusercontent.com/kcoderhtml/dfc6674cf92c540bf0952d6387e7feab/raw/031868036ef4b971e5fe07298252321b610e7569/docker-compose.yml"
# set container name to mc
# select what image we want to use
# configure variables
tty: true # equivalent for -t
stdin_open: true # equivalent for -i
# map storage for the server
# use a named, managed volume for data volume
# load configuration from env file
# expose the Minecraft server port outside of container
This YAML file tell docker compose to create a minecraft server using the image
itzg/minecraft-server:latestit also maps the data files of the server to the current directory, so you can add a custom world or edit the minecraft server config.
Create an environment file called
.envwhich will store the version information and whitelist. Don’t forget to set the proper memory value for your machine.
### Minecraft Server ###
# Set server type (vs the default of vanilla)
# whitelist any players you want seperated by commas
# set version information valid values: VANILLA | PAPER | FABRIC | FORGE
# set memory
# its recommended to set MAX_MEMORY to around 2 gigs less than
# the total amount of memory on your machine
Step 3 — Start the server:
Create a folder called
Run the following command to start the server:
docker compose up -d
If the server ever stops in the future than run the above command again to start it back up.
I hope you enjoy this tutorial and that it helped you in some way. Good luck!