General Information
This guide will walk you through the process of setting up a Valheim Dedicated Server with Docker. It will cover a few different use-cases, such as playing with mods, using an existing world, and starting with a new world.
In the following guide I am assuming the following scenario, you play games on a windows computer, and have an ubuntu/linux machine that you wish to host this server on. In my case its an ubuntu server VM running on my Proxmox machine. I also assume that whatever you decide to deploy this on, follows the System Requirements listed in the Docker Image. Lastly, and most importantly, I assume you have access to your router and are able to configure port forwarding on it. Otherwise, you’ll find yourself following this guide and getting stuck at the very end when we need to setup port forwarding. TL;DR Requirements
- A computer and server: A server to deploy the docker container and computer to play the game on
- Basic Command Line Knowledge: how to use
sudo
(password) and how to navigatenano
(arrow keys) - Access to router configuration: able to log into your router and setup port forwarding.
Installing Docker Compose
Source: Docker Documentation Plugin
I followed the instructions on the official Docker Documentation website and linked to it above, but I’ve added them here as well for those who don’t want to open another tab. I prefer to use Docker Compose as its easiest for me, and allows me to organize variables in a more readable way.
Update your package index and install the latest version of docker-compose-plugin
sudo apt-get update
sudo apt-get install docker-compose-plugin
To verify that Docker Compose installed correctly, check the docker version by running the following:
docker compose version
Your expected output should look like this: Docker Compose version v2.20.3
Creating a docker user
Next you will want a user to the docker group. I personally like having all my docker containers running off a single docker user, so I will show the steps to recreate how I did that.
First, create a docker user and the docker group:
sudo useradd -m docker
sudo usermod -aG docker docker
Next, you will want to create a secure password for your docker user:
sudo passwd docker
Creating directory for server data
This can be anywhere but I prefer to store the active data for docker containers under the docker user.
If you do decide to change the location of said folder, write it down, you will need it later.
Use the mkdir command to create a valheim-server directory under the docker user’s home directory:
sudo mkdir /home/docker/valheim-server
Decide: Mods, Existing World, New World
You now have three options to choose from. Do you want to play with mods, use an existing world, or create a new one? Each one of these has a little overlap with the other so if you want to play with mods, don’t worry about what world you want to use as it covers both of them.
I want to copy an existing world
(Mods) Installing Thunderstore Mod Manager/Launcher
First and Foremost, If you want to play mods, you are going to have to use a mod manager to, well… manage your mods. Valheim uses the Thunderstore Mod Manger to do this, which you have to download though Overwolf. You will be installing this on your host machine/computer you plan on playing on. (Most likely Windows)
You can download the Mod Manager from this link —> Overwolf | Tech for developers who love gaming Thunderstore Mod Manager - Desktop App on Overwolf
Once you’ve installed it, you will have to select “Server”
Then select “Valheim Dedicated Server” from the options below:
Next you will want to create a new profile with the “Create New” option. Type in the name you want and press “Create”
Select your new profile and navigate to “Get mods”
(Mods) Decide What Mods You Want (Server-Side)
Before we continue, make sure you download “BepInExPack_Valheim” as its required for all mods.
Now the fun part, sit down with your friends and decide what mods you all want to play.
Some QoL mods I enjoyed and would recommend:
MultiUserChest - Lets you and your friends access a chest at the same time
Quick_Stack_Store_Sort_Trash_Restock - Self explanatory, great after resource gathering to one click dump into chests
AzuCraftyBoxes - Lets you craft and build without having the items in your inventory as long as a nearby chest has them. Really nice so you don’t have to run back and forth grabbing every item for crafting.
(Mods) Creating Mod Config. Files
Once you have curated your mod list with your friends, you need to launch the dedicated server once. We will need the config files that get generated upon startup. This will take several minutes.
You will know that the server started up properly once you see something along the lines of Session "My server" with join code 563512 and [your IP] is active with 0 player(s)
You can go ahead and close the command prompt, shutting the server down. We have now generated the config folders we will be using.
Back in the mod manager, navigate to “Settings” then click the door icon on the second option “Browse profile folder”
This will open a file explorer, navigate to “..\BepInEx\Plugins”.
You should see some folders with the names of the mods you added earlier. You will want to note this location/file path down somewhere, or just keep the file explorer open.
(Mods) Sharing your mod profile with friends
To share your mod configuration with your friends, Click the share button in the top left of the Thunderstore Mod Manager.
You can copy this and send it to the people you wish to invite to your server. They will need this to connect to the server, otherwise they will get a “version incompatible” error when trying to join.
(Mods/Existing World) Starting an SFTP Server to Transfer Config. Files
If you are using mods or wish to use an existing world, then you are going to need to set up an SFTP connection between your host machine (Windows) and your server (Ubuntu).
I followed the following guide to set mine up: How to setup SFTP server on Ubuntu 22.04 - SFTPCloud
Once you complete the steps in the guide, continue to the next section.
(Mods/Existing World) Installing Filezilla - FTP Client on host machine
You can use whatever FTP client you would like to for this step, but I’m more familiar with Filezilla so I will be recommending it.
Install: FileZilla - The free FTP solution
Once installed, you should be at a screen like this:
(Mods/Existing World) Transferring Files
Now that you are here, you will want to connect to the SFTP server we created previously. The Host section will be your IP address (192.168.0.101), username will be the username you created (sftp_user) and password will be the password for said user. The Port you want to use is 22 as that is the port used for SFTP.
Press Quickconnect, and on the right side of the application you should see the following.
Click on sftp_user to navigate to the sftp_user.
On the left side of the application, navigate to the plugins folder we opened previously. In my case the filepath is C:\Users\Tortiee\AppData\Roaming\Thunderstore Mod Manager\DataFolder\Valheim\profiles\Defaultf\BepInEx\plugins\
Once you have clicked on the plugins folder, you should see something similar.
Next, you will drag the plugins folder to the sftp_user to copy the entire directory over. Once you see that the directory and its children have been copied over, you can close filezilla and move back to your server. Next you will want to delete the plugins folder under the docker user.
sudo rm -r /home/docker/valheim-server/bepinex/plugin
Then we will want to copy over the plugins folder with the configuration files that we transferred over.
sudo cp -r /home/sftp_user/plugins /home/docker/valheim-server/bepinex
Things to have written down
For the next step, you will want to make sure you have all the following written down somewhere.
(all): Docker uid and gid
id docker
Expected Output: uid=1001(docker) gid=1002(docker) groups=1002(docker)
(all): valheim-server directory location : /home/docker/valheim-server
(Existing World): world name without the .deb
file extension
Creating the Docker-Compose File
Create the docker-compose file that we will use:
touch docker-compose-valheim-server.yaml
Open nano to edit the docker-compose file
nano docker-compose-valheim-server.yaml
Take note of the comments in the following. The notes you wrote down earlier will be used to populate this file.
Copy and paste the following into the nano editor (Ctrl+Shift+V)
services:
valheim-server:
container_name: valheim-server
ports:
- 2456:2456/udp
- 2457:2457/udp
- 2458:2458/udp
volumes:
- /home/docker/valheim-server:/config
environment:
# Docker User - Change the PUID and GUID to the UID and GID you wrote down earlier
- PUID=1001
- PGID=1001
# General Environment variables
- SERVER_NAME= #Add server name that will appear in the server browser
- SERVER_PASS= #Add a password: default = secret
# IF USING AN EXISTING WORLD: Add the world name you wrote down earlier
# OTHERWISE: Just add whatver name you want for the world_name
- WORLD_NAME= #Add the world name
# Remove the Pound Sign below if you want to enable mods
#- BEPINEX=true
image: lloesche/valheim-server
- Under volumes, if you changed the “valheim-server” directory, update it. Make sure to keep the “:/config” to the end.
- Under Docker User, update the PUID and PGID to the corresponding uid and gid you wrote down earlier.
- SERVER_NAME and SERVER_PASS can be whatever you want it to be
- WORLD_NAME should be the existing world name without the .deb that you wrote down earlier, however if you are creating a world, then you can put whatever.
- BEPINEX=true, remove the pound sign in front of the dash if you wish to enable mods.
When you are finished and want to save and exit, Press Ctrl+X and then Y.
Starting the Server
Now to build the container and start the server. The following command will take the docker-compose file you just worked on and build the server based off the information you supplied it.
sudo docker compose --file docker-compose-valheim-server.yaml up --detach
Next, verify that the container was deployed:
sudo docker compose ps
Under “Status” you should see “Up x seconds”
Lastly, we want to check the logs for the server. If you are creating a new world, expect to wait up to 15 minutes depending on your computer hardware.
sudo docker compose logs valheim-server --follow
You will know when the server is up and ready to connect to once you see something along the lines of the following:
Feb 22 05:55:36 supervisord: valheim-server 02/22/2025 05:55:36: Console: [Info : Unity Log] 02/22/2025 05:55:36: Connections 3 ZDOS:798872 sent:119 recv:545
Feb 22 05:55:36 supervisord: valheim-server 02/22/2025 05:55:36: Connections 3 ZDOS:798872 sent:119 recv:545
When you need to stop following the log, use Ctrl+C.
Last Step - Port Forwarding
The last configuration thing you need to do is to setup port forwarding on your router. Every router is different, so I suggest consulting your routers user manual on how to do so.
You will want to forward the following range 2456-2458/UDP
You may see something along these lines once you are done:
Name | Device IP | External port | Internal Port | Protocol |
“Name” | “Server IP” | 2456-2458 | 2456-2458 | UDP |
Connecting to Server
Now you and your friends should be able to connect to your server! There is just one last step, giving your friends the connection information.
Take your server IP and add port 2456 to the end of it.
It should look like the image to the right.
Now send this to your friends and have them navigate to the “Join Game” screen and click “Add Server”
Once they add the server, have them press connect and you’re done!
Resources Used
Filezilla - FTP Client
FileZilla - The free FTP solution
How to Setup a SFTP Server
How to setup SFTP server on Ubuntu 22.04 - SFTPCloud
Valheim Server Docker Image
Setup Valheim Server With Docker
Ed Setting up a Valheim server using Docker
Closing remarks
Overall my server ran smoothly for all parties, myself and my friends. I would encounter some RAM issues, where the main base would start to struggle, fps drops, rubberbanding, delayed chest opening. I looked into the summary of the VM and saw that the memory usage was maxed out, and the occasional Docker or VM restart would fix the issues. I never determined if this was due to one of the mods, or if there was something like a memory leak as it would require more testing. Just something to keep an eye out on.
This project was mostly so my friends and I could play a game we all enjoy together, but I did use some of my skills and learned a few things along the way.
- I had never personally setup a SFTP server on a machine, but I had used a client plenty of times. I decided to go in that direction to transfer files between two computers on my local network, and it worked perfectly.
- I’ve gotten familiar with docker and the docker-compose plugin due to another project I am still working on, and found that I was able to create the docker-compose.yaml file without looking anything up. I did learn about the
docker logs
command through this project though, and the-follow
option proved to be very useful in this use-case. - I also wanted to get better at documenting my steps in a verbose/explanatory way. Sure, everyone can copy and paste commands, but I like knowing why we use those commands, and what they are doing. I wanted to try documenting my process so that in the future, I can look back on this and say “I liked that, I didn’t like how I did that” and improve upon it.
I also originally made the server with a new world and without mods. My friends decided that after a little while, they wanted to add mods to the server, and when I went to look up resources for my situation, I couldn’t find any. At least none that were step by step. I figured creating such a guide for people in the future could prove useful. It did take me a while looking at the docs for the docker image to figure out what exactly it wanted. Could be my lack of familiarity but the biggest thing I got hung up on was transferring the plugin folders/files. Personally, I don’t think it was explained well enough, and had some troubles getting the right things copied over, into the right places.
While I am sure there are easier ways to do certain things, I just wanted to get this server up and running and didn’t feel like I needed to find the most optimal solution to every step. Such and example is, I’m sure there is an easier way to transfer files. However, at the moment, the only way I know to transfer files between devices on my network is through file shares and SFTP. So I opted to use that, and since I’m familiar with Filezilla, I opted to use it as my SFTP client. I’ve used Filezilla for classes in the past and to help manage files for Minecraft servers I’ve hosted for different communities in the past. I’ve heard of a tool named WinSCP, which makes it seem like you don’t have to set up an SFTP server on the device you wish to transfer files to/from. However I lack familiarity with it, and the time it would take to familiarize myself with the software, and learn how to use it, outweighed my decision of just setting up a SFTP server and using a client.