Valheim Server Helper makes running your own Valheim server simple. It comes with an optional Discord bot to help administer the server remotely.
- Docker (or Podman)
- Docker Compose (or Podman Compose)
- Clone or download this repository
- Copy
docker-compose.yml
todocker-compose.override.yml
and modify its contents to suit your needs - In a shell where docker-compose is on the
PATH
, build the container:-
docker-compose build
-
The server is run via docker-compose
. Several volumes store SteamCMD, rbenv
, server files, and world files to reduce time needed to restart the container (or run multiple containers). The Discord bot code is also mounted in a volume to allow updates without Valheim server downtime.
- Run/restart the container (detached)
-
docker-compose up -d --force-recreate
-
- Stop/rm the container
-
docker-compose down
-
- Create a new Application for your Discord account here
- Create a Bot for your application and copy its secret token, pasting it in the
docker-compose.override.yaml
:-
VALHEIM_BOT_TOKEN: YOUR_BOT_TOKEN
-
- Copy the
Client ID
for your application and use it in this URL in your browser to add your bot to your server (replaceYOUR_BOT_CLIENT_ID_HERE
):-
https://discord.com/oauth2/authorize?client_id=YOUR_BOT_CLIENT_ID_HERE&scope=bot
-
- Enable Developer Mode in your Discord user settings in
User Settings -> App Settings -> Appearance -> Advanced -> Developer Mode
. This allows you to right-click channels and roles to copy their IDs for the next steps. - Create or designate an existing channel for the bot's announcements. Copy its ID into
docker-compose.override.yaml
:-
VALHEIM_BOT_CHANNEL_ID: 000000000000000000
-
- Create or designate an existing role for sensitive commands (
!restart
,!restart_bot
). Copy its ID intodocker-compose.override.yaml
:-
VALHEIM_BOT_ADMIN_ROLE_ID: 000000000000000000
-
- Create or designate an existing role for even more sensitive commands (
!update_bot
). Copy its ID intodocker-compose.override.yaml
:-
VALHEIM_BOT_OWNER_ROLE_ID: 000000000000000000
-
- If desired, install optional mods to enable RCON command support via the bot (primarily for ban/kick/save commands)
- Required mods:
- Install and configure the mods as directed
- IMPORTANT NOTE: With these mods, the password is not required even when set, so do not expose the RCON port beyond the container/host!
-
VALHEIM_BOT_RCON_PORT: 12345
- Once the container starts, your bot should show as online and be available for commands.
Commands are registered as integrated slash commands.
- Public comamnds:
/valheim info
- Print server info including name, current player count, type, OS, and version
- Example:
Name: Test Current players: 1 Type: Dedicated OS: Linux Version: 0.146.11
/valheim players
- Print active players. Player names are currently not reported by the server.
- Example:
• Unknown - 00:00:28
/valheim status
- Query whether the server is running (i.e. process still exists via
pgrep
)
- Query whether the server is running (i.e. process still exists via
- Admin commands:
/valheim rcon [command]
- Run the given RCON command; primarily useful for
ban
,kick
, andsave
commands
- Run the given RCON command; primarily useful for
/valheim restart
- Restart the Valheim server gracefully (via
SIGINT
). Status messages are printed to the designated channel as the server restarts. Server updates are applied during this process.
- Restart the Valheim server gracefully (via
/valheim restart_bot
- Restart the Discord bot to apply new source code changes without Valheim server downtime
With multiple compose files it's simple to run multiple containers on different port ranges.
- The server files, save location, etc. are on shared mounts between all servers.
- You must make sure each server has a unique
SERVER_WORLD
to avoid conflicts on causing missing items or progress as servers save their state. - You must only update one server at a time (as SteamCMD would conflict with itself if run via multiple containers simultaneously)
- Subsequent servers' updates will see the updated files and simply validate them
- Admins and bans must be shared across servers
- There is no guarantee bans will persist properly when running multiple servers, depending on when the server writes the bans file. (TODO: test this)
- You must make sure each server has a unique
- Copy
docker-compose.yml
to another file, e.g.docker-compose-new.yml
- Edit
docker-compose-new.yml
to utilize different ports. It is unknown whether changing the internal ports is required (SERVER_PORT
and latter port in theports
entries), but it doesn't hurt:-
environment: SERVER_PORT: 12456 ports: - "12456:12456/udp" - "12457:12457/udp" - "12458:12458/udp"
-
- Run your new server using a separate docker-compose project (
-p
) and the configured compose file (-f
) for compartmentalization:-
docker-compose -p new -f docker-compose-new.yml up -d
-
- Use the project name and compose file when interacting with that container, e.g. to stop the server:
-
docker-compose -p new -f docker-compose-new.yml down
-
For discussion, troubleshooting, etc., join us over on the unofficial Valheim Community Server Hosts Discord!