diff --git a/README.md b/README.md index d59163f..cc9a85a 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ with Spring framework and a Postgres database. - [`PHP`](https://github.com/docker/awesome-compose/tree/master/apache-php) - [`Traefik`](https://github.com/docker/awesome-compose/tree/master/traefik-golang) - [`Django`](https://github.com/docker/awesome-compose/tree/master/django) +- [`Minecraft server`](https://github.com/docker/awesome-compose/tree/master/minecraft) ## Basic setups for different platforms (not production ready - useful for personal use) - [`Gitea / PostgreSQL`](https://github.com/docker/awesome-compose/tree/master/gitea-postgres) - [`Nextcloud / PostgreSQL`](https://github.com/docker/awesome-compose/tree/master/nextcloud-postgres) diff --git a/minecraft/README.md b/minecraft/README.md new file mode 100644 index 0000000..8bb44c4 --- /dev/null +++ b/minecraft/README.md @@ -0,0 +1,82 @@ +## Minecraft server +This example defines a basic setup for a Minecraft server. More details on the Minecraft server docker image can be found [here](https://github.com/itzg/docker-minecraft-server/blob/master/README.md). + +Project structure: +``` +. +├── docker-compose.yaml +└── README.md +``` + +[_docker-compose.yaml_](docker-compose.yaml) +``` +services: + minecraft: + image: itzg/minecraft-server + ports: + - "25565:25565" + ... + volumes: + - "~/minecraft_data:/data" +``` + +When deploying this setup, docker-compose maps the Minecraft server port 25565 to +the same port of the host as specified in the compose file. The Minecraft client application can connect to this port directly. +This example maps the Minecraft data folder holding all game storage to ~/minecraft_data on the host. + +## Deploy with docker-compose + +``` +$ mkdir -p ~/minecraft_data +$ docker-compose up -d +WARNING: Some services (minecraft) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm. +Creating network "minecraft_default" with the default driver +Creating minecraft_minecraft_1 ... done +``` + +Note: this is using a volume in order to store Minecraft server data, that can be recovered if you remove the container and restart it. + +## Expected result + +Check containers are running and the port mapping: + +``` +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +7f696c2fb101 itzg/minecraft-server "/start" 5 minutes ago Up 5 minutes (healthy) +``` + +After running `docker-compose up`, the minecraft server takes a bit of time to initialize Minecraft world. You can follow the progress: + +``` +$ docker-compose logs +... +minecraft_1 | [15:06:39] [Worker-Main-6/INFO]: Preparing spawn area: 94% +minecraft_1 | [15:06:39] [Worker-Main-7/INFO]: Preparing spawn area: 94% +minecraft_1 | [15:06:39] [Server thread/INFO]: Time elapsed: 25620 ms +minecraft_1 | [15:06:39] [Server thread/INFO]: Done (35.526s)! For help, type "help" +minecraft_1 | [15:06:39] [Server thread/INFO]: Starting remote control listener +minecraft_1 | [15:06:39] [Server thread/INFO]: Thread RCON Listener started +minecraft_1 | [15:06:39] [RCON Listener #1/INFO]: RCON running on 0.0.0.0:25575 +``` + +Once it is initialized, run your Minecraft application, hit "Play", then "Multiplayer" and "Add server" +![add server](screenshots/click-add-server.png) + + Specify your new server IP : localhost:25565 + ![server configuration](screenshots/add-server-config.png) + + You can then start playing + ![ready to play](screenshots/ready-to-play.png) + +Stop and remove the containers + +``` +$ docker-compose down +``` + +To delete all data, remove all named volumes by passing the -v arguments: + +``` +$ docker-compose down -v +``` \ No newline at end of file diff --git a/minecraft/docker-compose.yml b/minecraft/docker-compose.yml new file mode 100644 index 0000000..7718b9c --- /dev/null +++ b/minecraft/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.7' +services: + minecraft: + image: itzg/minecraft-server + ports: + - "25565:25565" + environment: + EULA: "TRUE" + deploy: + resources: + limits: + memory: 1.5G + volumes: + - "~/minecraft_data:/data" diff --git a/minecraft/screenshots/add-server-config.png b/minecraft/screenshots/add-server-config.png new file mode 100644 index 0000000..d732950 Binary files /dev/null and b/minecraft/screenshots/add-server-config.png differ diff --git a/minecraft/screenshots/click-add-server.png b/minecraft/screenshots/click-add-server.png new file mode 100644 index 0000000..d3f2a42 Binary files /dev/null and b/minecraft/screenshots/click-add-server.png differ diff --git a/minecraft/screenshots/ready-to-play.png b/minecraft/screenshots/ready-to-play.png new file mode 100644 index 0000000..bd64e66 Binary files /dev/null and b/minecraft/screenshots/ready-to-play.png differ