Setting up a Valheim server using Docker
Setting up a Valheim server using Docker

Setting up a Valheim server using Docker

If you haven't heard of Valheim, where have you been!

VALHEIM
  • 3 million players in a matter of weeks.
  • Over 60,000 ‘Overwhelmingly Positive’ reviews.
  • Officially entered the Steam’s Top 250 best-reviewed games of all time.
  • Currently 7th most streamed game on twitch, surpassing CS:GO, Dota 2, Minecraft and Rust
  • Over 20 million hours of gameplay already watched.

With Valheim rising, people are playing on servers with their friends. The problem is, someone needs to host their world.

What happens when the friend needs a break from slaying trolls or punching trees? The server needs to be shut down, as it's running from their computer.

I'm going to talk through how to host a Valheim server on a docker image. This will enable you to set up a permanent server for all your friends to enjoy, 24/7.

Setting up your Valheim server

Require some assistance?

Our experts can help get you set up!

Find out more

Step 1: Setting up your server

Click to jump to Step 2: Installing Docker

You'll need to either have an existing server instance or create one. I use a Proxmox instance running on a server in my loft. You could also use something like Digital Ocean to run your Valheim server. Using the following link will give you $100 worth of credits for 60 days to play around with, just sign up using this link. That's almost 3 months of Valheim multiplayer, for free!

Once you're all set up you'll need to access your machine and run the following commands to get all your prerequisites installed!

Step 2: Installing Docker

Click to jump to Step 3: Setting up your Valheim Docker server

Once you have your Ubuntu instance up and running using any of the above methods, It's time to install Docker.

Firstly, we need to run an update to make sure that all our package repositories are up to date. You can do that by executing the following in your terminal window.

sudo apt-get update
sudo apt-get upgrade

This may take up to 10 minutes, allow it to sit, go make a cup of tea or play some more Valheim!

Once your upgrade has finished, we need to install Docker.

Docker allows us to run what's called containers on our Ubuntu instance. This means, in theory, we could run multiple Valheim instances on a single machine.

Install Docker by executing the following command

sudo apt-get install docker-ce docker-ce-cli containerd.io

This will install Docker, and its required dependencies to get up and running.

Finally, the last step for the Docker setup is to assign your user to the Docker group on your machine. This allows you to run Docker commands without needing to enter your sudo password. You can add your user to the Docker group by running the following command.

sudo usermod -aG docker $USER

You will be required to log out of your Ubuntu instance and log back in again. From the terminal, this can be done by executing the following command.

logout

Once you have logged back in, you can test that your user has been assigned to the Docker group by executing the following command.

docker -v

This will give you an output of the Docker version number that you have installed. Here's my Docker version output for reference.

~ docker -v
Docker version 19.03.8, build afacb8b7f0

Step 3: Setting up your Valheim Docker server

Now it's time to set up your Valheim Docker server.

You're only 15 minutes away from fighting Greydwarfs and Trolls.

Make sure that you're still logged into your Ubuntu instance. Change your working directory to your users' home by running the following command.

cd

We now need to create a directory that will be the home for our Valheim server. Let's create a new directory using the mkdir command.

mkdir valheim-server-config

This will create your Valheim server directory.

You now have 2 options. Do you want to copy an existing world (say, a singleplayer world that you have been playing on, that you'd like to share with your friends)?

Or, would you like to set up a brand new world and start again?

I'll copy my existing world

I'll create a new world for my server

Copying an existing world

To use an existing world, you will need to find your world files. On Windows, these can be found in the following location

C:\Users\Ed\AppData\LocalLow\IronGate\Valheim\worlds

Before copying, we need to make sure that we have created the worlds folder on our server. To do this, we need to cd into the config directory that we created earlier, and then make a new directory name worlds. You can achieve this by running the following commands.

cd
cd valheim-server-config
mkdir worlds
cd

So this will create the necessary worlds folder required to store your singleplayer world.

Now, back on your Windows machine, we need to copy all the files inside the C:\Users\Ed\AppData\LocalLow\IronGate\Valheim\worlds directory, over to the /home/$USER/valheim-server-config/worlds directory on your Ubuntu instance.

You can do this using something like WinSCP.

WinSCP
WinSCP is a popular free SFTP and FTP client for Windows, a powerful file manager that will improve your productivity. It supports also Amazon S3, FTPS, SCP and WebDAV protocols. Power users can automate WinSCP using .NET assembly.

Simply download WinSCP and log into your server using the WinSCP interface. This will allow you to upload and download files bi-directionally.

Make sure to only copy your singleplayer files, as we don't want to lose any data in the process.

Now, we want to start our new Valheim Docker server.

To do this, make sure you're back in your terminal window on your Ubuntu server. You're going to want to paste in the following Docker run command. This will start up your Docker container with some environment variables.

docker run -d --name valheim-server -p 2456-2458:2456-2458/udp -v $HOME/valheim-server-config:/config -e SERVER_NAME="CHANGE ME" -e WORLD_NAME="CHANGE ME" -e SERVER_PASS="CHANGE ME" lloesche/valheim-server

As you can see, you'll need to change some settings.

  • Make sure to change your Server Name. This is how your friends will find your server.
  • You must also change the World Name to match the world name of your singleplayer world. (This is also the name of the files you copied earlier).
  • And finally, you'll want to add a password to your server, which must be longer than 5 characters.

After you have that configured, press enter to execute the command.

Creating a new world

Make sure you're back in your terminal window on your Ubuntu server. You're going to want to paste in the following Docker run command. This will start up your Docker container with some environment variables.

docker run -d --name valheim-server -p 2456-2458:2456-2458/udp -v $HOME/valheim-server-config:/config -e SERVER_NAME="CHANGE ME" -e WORLD_NAME="CHANGE ME" -e SERVER_PASS="CHANGE ME" lloesche/valheim-server

As you can see, you'll need to change some settings.

  • Make sure to change your Server Name. This is how your friends will find your server.
  • You must also add a World Name, this can be anything you like.
  • And finally, you'll want to add a password to your server, which must be longer than 5 characters.

After you have that configured, press enter to execute the command.

Step 4: Starting your server

After executing the Docker run command. Docker will now pull down the latest Valheim Server image from the Docker repository. Once downloaded, Docker will spin up your instance.

Here's my build output for reference

Unable to find image 'lloesche/valheim-server:latest' locally
latest: Pulling from lloesche/valheim-server
def129c803cd: Pull complete
0a0ae35ee50c: Pull complete
916cfd6a854d: Pull complete
646ed4e69a7b: Pull complete
6df75d9bfbaa: Pull complete
57f45ab75b2a: Pull complete
Digest: sha256:879d8f7bdde4b3b873ded00aaff082e15f51302ef8f7246b71dda40c5dc58d2d
Status: Downloaded newer image for lloesche/valheim-server:latest
c5c56b37452fe12979d5ef378c412b934afb68fa29abdb5dc4d3cc2e66dbb556

You can check to see the status of your Valheim server by running the following docker command

docker ps

This will show you your valheim-server container instance. Like the following.

Let's check the status of our Valheim Server by copying the Container ID and using it with the following command.

docker logs c5c56b37452f # your container id

You'll see a huge output from that command. But one of the last lines should look like the following.

Game server connected

Step 5: Connecting to our Valheim server

You can either connect to your Valheim server locally or over the internet.

To connect over LAN, I recommend the following instructions.

lloesche/valheim-server-docker
Valheim dedicated gameserver in Docker with automatic update and world backup support - lloesche/valheim-server-docker

Connecting over the internet means that your friends can also connect to your Valheim server.

To allow your friends to connect, you need to port-forward your server. There are a million different tutorials on the web for how to port-forward for your router.

Here's a handy guide.

You'll need to forward the following ports 2456, 2457, 2458 all to your server address

If you set up your server on Digital Ocean, you'll need to configure UFW. Which I have a handy guide for.

Setting Up UFW on Ubuntu Server
UFW is a program that allows you to internally control ports on your Linux instance. This gives you the ability to forward ports from your machine.

Once all configured, we can connect to our Valheim Server.

Start up Valheim. Navigate to the Join Game tab. You will then have to select the Community option.

You can now search for your server. Remember we configured the name when we ran the Docker command?

Here's mine.

Select it and hit Connect.

You will then be prompted for a password.

Enter your password which we configured in our Docker setup and hit enter.

If all went well...

That's all there is to it

Hopefully, everything should be up and running successfully. Let me know if you receive any issues in the comments, I'll be happy to help you out.

This post contains affiliate links, meaning we may receive a small commission on purchases made through links in this post. At no extra cost to you 😊

We hate Ads! They don't respect your privacy.

Would you consider supporting us on buy me a coffee? Your support really helps to keep the costs down with running the blog

Enjoying the post?

Subscribe to our free Weekly Newsletter, featuring our latest posts. Straight to your inbox. No spam ever (we hate it as much as you do).