docker.recipes

Valheim Dedicated Server

beginner

Valheim dedicated game server with auto-updates.

Overview

Valheim is a popular survival and sandbox video game inspired by Norse mythology that supports cooperative multiplayer gameplay for up to 10 players. Released in early access by Iron Gate Studio in 2021, Valheim became a massive hit with millions of players exploring its procedurally generated Viking world. The game requires a dedicated server to enable persistent multiplayer worlds where friends can build, explore, and survive together even when the host player is offline. This Docker stack deploys the lloesche/valheim-server container, which provides a complete Valheim dedicated server environment with automatic Steam updates and world persistence. The container handles all the complexities of running a Steam-based game server, including downloading game files, managing world saves, and keeping the server updated with the latest patches. The setup exposes the necessary UDP and TCP ports for Valheim's networking protocol while maintaining isolated storage for configuration and world data. This configuration is ideal for gaming communities, friend groups, and content creators who want to maintain persistent Valheim worlds without requiring a host player to always be online. Server administrators benefit from automated updates, easy backup management through Docker volumes, and the ability to customize server settings through environment variables. The stack is particularly valuable for groups planning long-term Valheim campaigns where world persistence and server reliability are crucial.

Key Features

  • Automatic Steam client and Valheim game updates without server downtime
  • Persistent world saves and player progression stored in dedicated Docker volumes
  • Built-in Steam server browser integration for easy discovery by players
  • Configurable server visibility settings for private or public server hosting
  • Support for custom world seeds and server naming through environment variables
  • Automatic server restart capabilities with world backup protection
  • Multi-port UDP/TCP networking optimized for Valheim's connection requirements
  • SYS_NICE capability for improved server performance and process prioritization

Common Use Cases

  • 1Gaming communities hosting persistent Viking survival servers for 24/7 access
  • 2Friend groups maintaining shared Valheim worlds across different time zones
  • 3Content creators running public servers for streaming and video production
  • 4Educational institutions teaching game server administration and Docker concepts
  • 5Homelab enthusiasts providing game hosting services for family and friends
  • 6Gaming cafes or LAN centers offering dedicated Valheim server instances
  • 7Discord communities building collaborative Norse mythology-themed settlements

Prerequisites

  • Docker host with at least 4GB RAM and 8GB storage for game files and worlds
  • UDP ports 2456-2458 and TCP port 2456 accessible through firewall
  • Stable internet connection with sufficient bandwidth for 10 concurrent players
  • Basic understanding of Valheim gameplay mechanics and server administration
  • Steam account knowledge for understanding game updates and server browser
  • Network configuration access for port forwarding if hosting from home network

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 valheim:
3 image: lloesche/valheim-server:latest
4 container_name: valheim
5 restart: unless-stopped
6 ports:
7 - "${SERVER_PORT:-2456}:2456/udp"
8 - "${SERVER_PORT:-2456}:2456/tcp"
9 - "2457:2457/udp"
10 - "2458:2458/udp"
11 environment:
12 - SERVER_NAME=${SERVER_NAME:-My Valheim Server}
13 - WORLD_NAME=${WORLD_NAME:-Dedicated}
14 - SERVER_PASS=${SERVER_PASS:-secret}
15 - SERVER_PUBLIC=${SERVER_PUBLIC:-true}
16 volumes:
17 - valheim_config:/config
18 - valheim_data:/opt/valheim
19 cap_add:
20 - SYS_NICE
21 networks:
22 - valheim-network
23
24volumes:
25 valheim_config:
26 valheim_data:
27
28networks:
29 valheim-network:
30 driver: bridge

.env Template

.env
1# Valheim Server
2SERVER_PORT=2456
3SERVER_NAME=My Valheim Server
4WORLD_NAME=Dedicated
5SERVER_PASS=secret
6SERVER_PUBLIC=true

Usage Notes

  1. 1Server at localhost:2456
  2. 2Min 5 char password required
  3. 3Auto-updates enabled
  4. 4World saves in config volume

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 valheim:
5 image: lloesche/valheim-server:latest
6 container_name: valheim
7 restart: unless-stopped
8 ports:
9 - "${SERVER_PORT:-2456}:2456/udp"
10 - "${SERVER_PORT:-2456}:2456/tcp"
11 - "2457:2457/udp"
12 - "2458:2458/udp"
13 environment:
14 - SERVER_NAME=${SERVER_NAME:-My Valheim Server}
15 - WORLD_NAME=${WORLD_NAME:-Dedicated}
16 - SERVER_PASS=${SERVER_PASS:-secret}
17 - SERVER_PUBLIC=${SERVER_PUBLIC:-true}
18 volumes:
19 - valheim_config:/config
20 - valheim_data:/opt/valheim
21 cap_add:
22 - SYS_NICE
23 networks:
24 - valheim-network
25
26volumes:
27 valheim_config:
28 valheim_data:
29
30networks:
31 valheim-network:
32 driver: bridge
33EOF
34
35# 2. Create the .env file
36cat > .env << 'EOF'
37# Valheim Server
38SERVER_PORT=2456
39SERVER_NAME=My Valheim Server
40WORLD_NAME=Dedicated
41SERVER_PASS=secret
42SERVER_PUBLIC=true
43EOF
44
45# 3. Start the services
46docker compose up -d
47
48# 4. View logs
49docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/valheim-server/run | bash

Troubleshooting

  • Server not appearing in Steam browser: Verify SERVER_PUBLIC is set to true and ports 2456-2458 are properly forwarded
  • Players cannot connect with 'Failed to connect' error: Check that SERVER_PASS matches exactly what players are entering (minimum 5 characters required)
  • Container exits with Steam update errors: Ensure sufficient disk space is available and restart container to retry Steam client download
  • World data lost after container restart: Verify valheim_config and valheim_data volumes are properly mounted and not being recreated
  • High CPU usage and poor performance: Ensure SYS_NICE capability is enabled and consider increasing Docker host resources
  • Server crashes during world generation: Increase available memory allocation and ensure WORLD_NAME contains only valid filename characters

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space