|
| 1 | +# PocketMine-MP Docker image |
| 2 | +This folder contains the files used to build and test the `pmmp/pocketmine-mp` Docker image. |
| 3 | + |
| 4 | +Docker is an easy, safe way to run software in a container where it can't affect anything else on your machine. |
| 5 | +You don't need to build any dependencies, and updating is as simple as changing the version number of the image you're using. |
| 6 | + |
| 7 | +## Pre-requisites |
| 8 | +To install Docker, refer to the [official Docker docs](https://docs.docker.com/engine/install/). |
| 9 | + |
| 10 | +## Running PocketMine-MP from Docker (using Docker Hub) |
| 11 | +This is really easy once you have `docker` installed. |
| 12 | + |
| 13 | +``` |
| 14 | +mkdir wherever-you-want |
| 15 | +cd wherever-you-want |
| 16 | +mkdir data plugins |
| 17 | +sudo chown -R 1000:1000 data plugins |
| 18 | +docker run -it -p 19132:19132/udp -v $PWD/data:/data -v $PWD/plugins:/plugins ghcr.io/pmmp/pocketmine-mp |
| 19 | +``` |
| 20 | + |
| 21 | +To run a specific version, just add it to the end of the command, like this: |
| 22 | +``` |
| 23 | +docker run -it -p 19132:19132/udp -v $PWD/data:/data -v $PWD/plugins:/plugins ghcr.io/pmmp/pocketmine-mp:4.0.0 |
| 24 | +``` |
| 25 | + |
| 26 | +## Changing the server port |
| 27 | +Docker allows you to map ports, so you don't need to edit `server.properties`. |
| 28 | + |
| 29 | +In the run command shown above, change `19132:19132/udp` to `<port number you want>:19132/udp`. **Note: Do not change the second number.** |
| 30 | + |
| 31 | +> [!WARNING] |
| 32 | +> Do not change the port in `server.properties`. This is unnecessary when using Docker and will make things more complicated. |
| 33 | +
|
| 34 | +## Editing the server data |
| 35 | +The server data (e.g. worlds, `server.properties`, etc.) will be stored in the `data` folder you created above. |
| 36 | + |
| 37 | +**Note: If you add new files (e.g. a world), don't forget to change the ownership of the file/folder to `1000:1000`**: |
| 38 | +``` |
| 39 | +sudo chown -R 1000:1000 <file/folder you added> |
| 40 | +``` |
| 41 | +This is needed to make the server able to access the file/folder. |
| 42 | + |
| 43 | +## Adding plugins |
| 44 | +Plugins can be added by putting them in `plugins` folder you created earlier. |
| 45 | + |
| 46 | + |
| 47 | +**Note: If you add new files, don't forget to change the ownership of the file/folder to `1000:1000`: |
| 48 | +``` |
| 49 | +sudo chown -R 1000:1000 <file/folder you added> |
| 50 | +``` |
| 51 | +This is needed to make the server able to access the file/folder. |
| 52 | + |
| 53 | +## Run the server in the background |
| 54 | +To run the server in the background, simply change `-it` to `-itd` in the last command above. |
| 55 | +This will run the server in the background even if you closed console. (No need to `screen`/`tmux` anymore!) |
| 56 | + |
| 57 | +### Opening the console of the server |
| 58 | +Use `docker ps` to see a list of running containers. It will look like this: |
| 59 | +``` |
| 60 | +user@DYLANS-PC:~/pm-docker-test$ docker ps |
| 61 | +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
| 62 | +dc20edd3dd62 pmmp/pocketmine-mp:4.0.0 "start-pocketmine" 7 seconds ago Up 6 seconds 19132/tcp, 0.0.0.0:19132-19133->19132-19133/udp, :::19132-19133->19132-19133/udp brave_dijkstra |
| 63 | +``` |
| 64 | +In this case, the container name is `brave_dijkstra`, but it might be something else in your case. |
| 65 | + |
| 66 | +To open the console, run the following command: |
| 67 | + |
| 68 | +``` |
| 69 | +docker attach <container name you saw in docker ps> |
| 70 | +``` |
| 71 | + |
| 72 | +To leave the console, just press `Ctrl p` `Ctrl q`. |
| 73 | + |
| 74 | +### Viewing the logs |
| 75 | +To see the logs, run the following command: |
| 76 | +``` |
| 77 | +docker logs --tail=100 <container name you saw in docker ps> |
| 78 | +``` |
| 79 | +Change `--tail=100` to the number of recent lines in the log you want to see. |
| 80 | + |
| 81 | +## Adding plugins from Poggit |
| 82 | +If the `$POCKETMINE_PLUGINS` is set, the container will auto-download the plugins specified from https://poggit.pmmp.io |
| 83 | +before starting PocketMine-MP. |
| 84 | + |
| 85 | +The list of plugins should be given in the format `PluginOne:1.2.3 PluginTwo:4.5.6`. The version part (`:4.5.6`) is optional. |
| 86 | + |
| 87 | +> [!CAUTION] |
| 88 | +> Plugins won't be redownloaded if they're already in the `plugins` volume, even if the version is different. |
| 89 | +> If you need to update a plugin, you'll need to delete the old plugin `.phar` first. |
| 90 | +
|
| 91 | +## Volumes |
| 92 | +- `/data` is a read-write data directory where PocketMine stores all data in. |
| 93 | + This includes PocketMine config files, player data, worlds and plugin config files/data. |
| 94 | +- `/plugins` is a read-only data directory where PocketMine loads plugins from. |
| 95 | + |
| 96 | +## Advanced usage: Passing args to PocketMine-MP.phar inside the container |
| 97 | +The `POCKETMINE_ARGS` environment variable will be passed to `PocketMine-MP.phar` when run. |
| 98 | + |
| 99 | +## Building this image |
| 100 | +The Dockerfile requires a build-arg `GIT_HASH` to fill the git hash metadata when building `PocketMine-MP.phar`. |
| 101 | +This ensures that `/version`, crash reports, logs etc. report the correct server version. |
0 commit comments