This is a overview on how I selfhosted my own minecraft server on my own ubuntu server safely and manage to make it joinable to others. I used itzg/minecraft-server image and made a tunnel via playit.gg so that anyone could connect without the need for port fowarding.
- Ansible: Downloads docker and sets it up automatically
- Docker-compose: Where the configs for the server are located
- playit.gg tunnel: Makes it so you can play with friends on the same server without having to expose home router with port forwarding
- RCON: Enabled for bot/automation integrations
- Auto-pause: Pause server when no players are online for a certain amount of time (saves resources)
- A playit.gg account and agent secret key (this will go into the .env file later for saftey)
git clone https://github.com/lukas362/selfhost-minecraft.gitRun the playbook to install Docker on your server:
ansible-playbook -i inventory.ini playbook.yml.envThen fill in your secrets:
MC_RCON_PASSWORD=your_secure_rcon_password
PLAYIT_SECRET_TOKEN=your_playit_agent_tokendocker compose up -d| Action | Command |
|---|---|
| Start server | docker compose up -d |
| Stop server | docker compose stop |
| Restart server | docker compose restart |
| Check status | docker compose ps |
| View MC logs | docker compose logs -f mc |
| View tunnel logs | docker compose logs -f playit |
| Port | Purpose |
|---|---|
25565 |
Minecraft |
25575 |
RCON |
Feel free to fork and adapt this for your own server needs.