Using Docker for Game Server Hosting

Docker is a containerization platform that packages software into standardized units (containers). For game server hosting, it offers major advantages: isolation, reproducibility, and easy management. In this article, we explain how to use Docker for your game servers.

Why Docker for game servers?

  • Isolation: each container is independent. A crash in one game server does not affect the others.
  • Consistency: a container works the same everywhere, whether it is your laptop or a production server.
  • Quick setup: a new server is ready in seconds.
  • Easy updates: pull a new image, restart the container, done.
  • Resource control: set a maximum per container for CPU and RAM.

Installing Docker

# Ubuntu/Debian
apt update
apt install docker.io docker-compose-v2
systemctl enable docker
systemctl start docker

Example: Minecraft server in Docker

Use the popular itzg/minecraft-server image:

docker run -d \
  --name minecraft \
  -p 25565:25565 \
  -e EULA=TRUE \
  -e TYPE=PAPER \
  -e VERSION=LATEST \
  -e MEMORY=4G \
  -v /data/minecraft:/data \
  itzg/minecraft-server

That is all. A Paper server with 4 GB RAM, accessible on port 25565, with data stored in /data/minecraft.

Docker Compose

For multiple servers, use Docker Compose. Create a docker-compose.yml:

services:
  minecraft:
    image: itzg/minecraft-server
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: PAPER
      MEMORY: 4G
    volumes:
      - ./minecraft-data:/data
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 5G
          cpus: "2.0"

  terraria:
    image: ryshe/terraria
    ports:
      - "7777:7777"
    volumes:
      - ./terraria-data:/root/.local/share/Terraria/Worlds
    restart: unless-stopped

Start everything with: docker compose up -d

Setting resource limits

Limit how many resources each container can use:

docker run -d \
  --name minecraft \
  --memory=5g \
  --cpus=2.0 \
  ...

This prevents one server from consuming all your resources and affecting other servers or the host system.

Management commands

docker ps                  Show running containers
docker logs minecraft      View logs of a container
docker stop minecraft      Stop a container
docker start minecraft     Start a container
docker restart minecraft   Restart a container
docker exec -it minecraft bash  Open a shell in the container

Backups with Docker

Because all data is in volumes, backing up is simple:

# Stop the container (optional, for consistency)
docker stop minecraft

# Copy the data
tar -czf minecraft-backup.tar.gz /data/minecraft/

# Start again
docker start minecraft

Docker vs. Pterodactyl

Pterodactyl uses Docker under the hood! The difference is that Pterodactyl provides a web interface on top of Docker, including user management, file manager, and console. If you are comfortable with the command line, you can use Docker directly for more flexibility.

Does Docker slow down my game server?

No, Docker containers run natively on the host kernel. The overhead is minimal (less than 1%). This is different from virtualization (VPS), where a full OS layer is simulated.

Can I use Docker on any VPS?

On most, yes. You need a Linux VPS with KVM or bare-metal virtualization. OpenVZ containers often do not support Docker. At HostValues, Docker runs without issues on our KVM-based VPSes.

Is Docker secure for game servers?

Yes, Docker provides extra security through isolation. A compromised container does not have access to other containers or the host system. Do use official images and keep them updated.

Run Docker on a VPS at HostValues with KVM virtualization and root access.


Still stuck? Open a support ticket and our team will help you out.

Back to the blog