Running Your First Docker Container: A Minecraft Server in Minutes
From Zero to Server with a Single Command
One of the most exciting things about Docker, as shown in the ‘Ubuntu System Administration Guide’, is how quickly you can get complex applications running. As a first example, the book demonstrates how to launch a fully functional Minecraft server using a pre-built image from Docker Hub.
The Docker Run Command
With Docker installed, you can start the server with a single command:
docker run -it -e EULA=true -p 25565:25565 --name mc itzg/minecraft-server
This command does several things: it downloads the `itzg/minecraft-server` image, accepts the End User License Agreement, maps port 25565 on your computer to the container’s port, and starts the server. In just a few moments, you’ll have a Minecraft server ready for players to join.
Persisting Your Data
A key concept is data persistence. By adding a ‘volume’ mapping (`-v minecraft_data:/data`) to the command, you can save the Minecraft world data to a folder on your host machine, ensuring that your world is safe even if you stop and remove the container.
This post is based from content of the book Ubuntu System adminstration guide. And the book can be found here https://www.amazon.com/stores/Mattias-Hemmingsson/author/B0FF5CQX13