Setup

Running a Game Server in Docker at Home (Compose Examples)

Run Minecraft, Valheim or Palworld servers in Docker at home with docker compose: images, ports, volumes, restarts, updates, backups and the firewall trap.

Updated Oct 7, 2026 · 5 min read

On this page

Running a game server in Docker at home means writing a short compose.yaml with a community image (such as itzg/minecraft-server, lloesche/valheim-server or thijsvanloef/palworld-server-docker), publishing the game's ports with the right protocol, mounting a folder for the world data, and setting restart: unless-stopped. Then docker compose up -d starts it, and it comes back after reboots on its own. You still need router port forwarding, and Docker's published ports bypass ufw on Linux, which catches a lot of people.

Why Docker for a home game server

  • Clean installs. Each server lives in its own container with its own dependencies (Java versions, SteamCMD, Wine). Nothing clutters the host.
  • Easy restarts and auto start. restart: unless-stopped brings servers back after crashes and reboots.
  • Several servers on one box. Run a Minecraft server and a Valheim server side by side on different ports.
  • Repeatable. Your compose.yaml documents the whole setup. Rebuild on a new machine in minutes.

Docker works best on a Linux host. On Windows, Docker Desktop runs containers inside a WSL 2 virtual machine, which works but uses more RAM and adds a layer to troubleshoot.

Install Docker

On Ubuntu or Debian, Docker's convenience script installs the engine and the compose plugin:

curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER

Log out and back in so your user can run docker without sudo. Check with docker compose version.

Example 1: Minecraft Java

itzg/minecraft-server is the most widely used Minecraft image. It downloads the server type and version you ask for.

services:
  mc:
    image: itzg/minecraft-server
    container_name: mc
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: "PAPER"
      VERSION: "LATEST"
      MEMORY: "4G"
    volumes:
      - ./mc-data:/data
    restart: unless-stopped

Save as compose.yaml in a new folder, then:

docker compose up -d
docker logs -f mc

The world, configs and plugins live in ./mc-data on the host. For console commands, the image includes rcon-cli:

docker exec -i mc rcon-cli

Example 2: Valheim

services:
  valheim:
    image: lloesche/valheim-server
    container_name: valheim
    cap_add:
      - sys_nice
    ports:
      - "2456-2457:2456-2457/udp"
    environment:
      SERVER_NAME: "Our Valheim"
      WORLD_NAME: "Midgard"
      SERVER_PASS: "change-me-123"
      SERVER_PUBLIC: "false"
    volumes:
      - ./valheim-config:/config
      - ./valheim-data:/opt/valheim
    restart: unless-stopped

Note the /udp on the port line. Without it Docker publishes TCP only, and Valheim, like most Steam games, needs UDP. This one mistake accounts for many "container runs but nobody can join" posts. The password must be at least five characters and must not appear inside the server name.

Example 3: Palworld

thijsvanloef/palworld-server-docker publishes 8211 UDP for the game and 27015 UDP for the server list query:

services:
  palworld:
    image: thijsvanloef/palworld-server-docker:latest
    container_name: palworld
    ports:
      - "8211:8211/udp"
      - "27015:27015/udp"
    environment:
      PLAYERS: 16
      SERVER_PASSWORD: "change-me"
      MULTIPLAYER: "true"
    volumes:
      - ./palworld:/palworld
    restart: unless-stopped

Check each image's documentation for the full list of environment variables. Image authors rename them over time.

Ports and the network

  1. Publish with the right protocol: "port:port/udp" for UDP, plain "port:port" for TCP, and both lines if the game needs both.
  2. Forward on your router to the Docker host's LAN IP, not the container's internal IP. See how to port forward a game server.
  3. Firewall: Docker inserts its own iptables rules for published ports, which bypass ufw. A port you publish is reachable even if ufw says deny. To keep admin ports private, bind them to localhost: "127.0.0.1:25575:25575". More in Linux firewall for game servers.
  4. Behind CGNAT, run a tunnel agent alongside. playit.gg publishes a Docker image; see playit.gg game server setup.

Updates

Most Steam game images update the game on container start. Many also have built in update checks controlled by environment variables. To pull a newer image:

docker compose pull
docker compose up -d

Pin the image to a version tag instead of latest if you want updates only when you choose.

Backups

Because the world sits in a host folder, backups are just file copies. Stop the server (or use the image's save command) first so files are consistent:

docker compose stop valheim
tar czf valheim-$(date +%F).tar.gz valheim-config
docker compose start valheim

Several images, including the Valheim one above, have built in scheduled backups you can enable with environment variables. Copy backups to another disk or cloud storage. Our backup guide covers what to keep.

Resource limits

Containers share the host's RAM and CPU. Cap a heavy server so it cannot starve the others:

    deploy:
      resources:
        limits:
          memory: 8g

For Java servers, keep the JVM memory (MEMORY in the Minecraft image) a gigabyte or two below the container limit, or the container gets killed for running out of memory.

Common problems

  • Container restarts in a loop. Run docker logs <name>. Usually a missing EULA, bad password rules or not enough RAM.
  • Nobody can join, logs look fine. Check /udp on the port line, then the router forward, then whether you are behind CGNAT.
  • Server not in the in-game browser. The query port is not published or forwarded.
  • Permission errors on volumes. Images often run as a specific user ID. Set PUID/PGID or UID/GID as the image docs describe.

Gameplay from Valheim

Same idea, without the home lab

Docker gives you a tidy home server, but the host still needs to stay on, your upload still carries the players and your router still needs forwarding. GamezServers runs servers for you in the same isolated way, with its own address, open ports, a panel exposing every setting in the game's server template, a live console, SFTP and one click backups. See Valheim hosting or Palworld hosting.

FAQ

Is Docker good for game servers?

Yes. It keeps each server isolated, makes restarts and updates simple, and lets you run several servers on one machine. Performance overhead on Linux is negligible.

Can I run Docker game servers on Windows?

Yes, through Docker Desktop with WSL 2. It works but uses more memory, and networking problems are harder to diagnose than on Linux.

Why can nobody join my Docker Valheim server?

Most often the port mapping is missing /udp. Valheim needs 2456-2457/udp, plus a router forward to the host's LAN IP.

Where is my world saved in Docker?

In the host folder you mounted as a volume, for example ./valheim-config. If you did not mount one, the world lives inside the container and is lost when it is removed.

Want a server without the setup?

From75¢

Pick a game, pay, play. Live the moment checkout finishes.

Keep reading