Running a Valheim Dedicated Server in Docker on Linux

If you already run a Linux box — a home server, a NAS, or a cheap VPS — Docker is the tidiest way to host Valheim. One container holds SteamCMD, the server binary, and the runtime, so your host stays clean, updates are one command, and you can move the whole thing to another machine by copying a folder. This guide uses the well-maintained lloesche/valheim-server image and Docker Compose.

Prerequisites

  • A 64-bit Linux host with Docker Engine and the Docker Compose plugin installed.
  • At least 2 GB RAM free for the server, plus a little headroom for the container.
  • Root or a user in the docker group.
  • UDP ports 2456–2457 reachable — open them in your firewall and, for internet play, forward them on your router.

The container downloads the free dedicated-server package itself, so there’s nothing to install from Steam by hand.

Step 1: Lay out a project folder

Keep the config and the game data on the host so nothing important lives inside the container. Create a directory and two subfolders for bind-mounts:

mkdir -p ~/valheim/config ~/valheim/data
cd ~/valheim

config will hold server settings, worlds, and admin lists; data holds the server install and BepInEx if you add mods later. Because both are on the host, destroying and recreating the container never loses your world.

Step 2: Write docker-compose.yml

Create ~/valheim/docker-compose.yml:

services:
  valheim:
    image: lloesche/valheim-server
    container_name: valheim
    restart: unless-stopped
    cap_add:
      - SYS_NICE
    ports:
      - "2456-2457:2456-2457/udp"
    volumes:
      - ./config:/config
      - ./data:/opt/valheim
    environment:
      SERVER_NAME: "My Viking World"
      WORLD_NAME: "Midgard"
      SERVER_PASS: "longboat"
      SERVER_PUBLIC: "true"
      SERVER_ARGS: "-crossplay"
      TZ: "America/New_York"
      UPDATE_INTERVAL: "900"
      BACKUPS: "true"
      BACKUPS_INTERVAL: "3600"
      BACKUPS_MAX_AGE: "3"

What the important settings do:

  • SERVER_PASS must be at least five characters and can’t be part of SERVER_NAME, the same rule the game enforces everywhere.
  • SERVER_PUBLIC: "true" lists the server in the community browser; "false" keeps it join-by-IP only.
  • SERVER_ARGS: "-crossplay" passes extra flags straight to the server binary — here, enabling crossplay so non-Steam players can join.
  • UPDATE_INTERVAL (seconds) tells the container to check for and apply game updates on its own, then restart the server. This keeps you compatible with patched clients.
  • BACKUPS turns on scheduled world backups written under /config/backups, pruned after BACKUPS_MAX_AGE days. More on that below.
  • cap_add: SYS_NICE lets the server adjust its own scheduling priority, which the image uses to keep the tick rate steady.

Step 3: Start it

Bring the stack up in the background:

docker compose up -d

The first launch is slow: the container downloads the dedicated server (App ID 896660) via SteamCMD before it boots the world. Watch the progress with:

docker compose logs -f valheim

When you see the world load and Game server connected, it’s live. Ctrl+C stops following the logs without stopping the container.

Step 4: Connect

In Valheim, choose Join Game → Join IP and enter your host’s address plus the game port — your.server.ip:2456 — then the password. For a VPS that’s the public IP; on a home LAN it’s the machine’s local IP, with UDP 2456–2457 forwarded on the router for outside friends.

Managing the server

Because everything lives under ~/valheim, day-to-day admin is just files and Compose:

  • Edit settings: change an environment variable, then docker compose up -d to recreate the container with the new value.
  • Restart: docker compose restart valheim.
  • Stop cleanly: docker compose down — the image traps the shutdown signal so the world saves before the container exits.
  • Admins and bans: edit config/adminlist.txt, config/permittedlist.txt, and config/bannedlist.txt (one SteamID64 per line). The server picks up changes without a full reinstall.

Backups

With BACKUPS: "true" the container drops timestamped archives of your world into config/backups on a schedule. For an off-box copy — the kind that survives the whole machine dying — sync that folder somewhere else with a nightly cron job:

0 4 * * * rsync -a ~/valheim/config/backups/ user@backup-host:/valheim-backups/

If you ever need to restore, stop the container, drop the .db and .fwl files from a backup into config/worlds_local, and start it again.

Updating the image

Auto-updates handle the game; to update the container image itself, pull and recreate:

docker compose pull
docker compose up -d

That’s the appeal of the Docker approach: the messy parts — SteamCMD, the runtime, update scheduling, and backups — are handled inside a container you can rebuild at any time, while your world and settings sit safely in two folders on the host.