Jump to content

Valheim Server on Raspberry Pi

Hey guys!

 

Yesterday, I finished my little project and I should I would share it here.

I always wanted to have a 24/7 running server for Valheim, since I want me and my friends to be able to build, hunt, collect whenever we want to in between killing bosses and sailing the world.

Since letting any PC run for 24/7 sucks a lot of energy and renting an external server goes against my codex of being a cheap-ass, I've been trying to get it running on an RPI4.

I've tried it months ago with TwisterOS but failed hilariously. Recently, I installed RPI-OS64, tried it again and it freaking worked!

So I thought I'd build a container and share it, since I couldn't find a Valheim-ARM64 Container on Docker Hub and I feel damn cool to be the first to push one! 😄

 

https://hub.docker.com/r/arokan/raspiheim

For this, I used box86 to run the steamcmd and box64 to run the server. It was a little tricky and it shows error after error, but I have not seen any short-comings yet.


You'll need a Raspberry Pi 4 with >=4GB RAM, since Valheim already uses two of them, and a 64-bit OS installed. If anyone gets it working on an RPI3, let me know!
Overclocking to 2Ghz is as far as I can judge not necessary -> 30-40% CPU-usage at 2Ghz.

 

For best practice, here are some tips for yet inexperienced users:
- Get a dynamic DNS from https://www.noip.com/ in order for your server to be always available. Tell your router or your pi to update your IP frequently. Further guides are easily available everywhere.

- Assign a static network-IP to your pi and enable port-forwarding with port 2456/udp to that IP.

- When installing Docker, use the official Documentation. I failed to install docker correctly using external guides and it hasn't been fun fixing it. Don't be scared, it's mostly copy&paste.

- Use a strong password or even the permitted-list.

 

That's basically it. I really hope you have fun hosting your own Valheim Server on your little Raspberry Pi!

P.S.: If 10-15 people request a complete guide, I will make one.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

hey i really could use some help with a guide if you have time. contacted on discord 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

Hi. A complet guide would really be appreciated.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 3 months later...

This is great!! I can't wait to try this out. When I do, I'll be sure to post here how well it does.

 

As for a guide, I can post here a quick setup:

 

1. Install docker:

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh
$ groupadd docker; sudo usermod -aG docker $USER
 

2. Create a directory for your Valheim server and enter it:

$ mkdir valheim-server
$ cd valheim-server

 

3. Within the Valheim directory, create the docker-compose file:

$ touch docker-compose.yaml

 

4. Copy paste the docker-compose-yaml example from the Docker hub page into your machine

version: "3"

services:
  raspiheim:
    image: arokan/raspiheim:latest
    container_name: raspiheim
    environment:
      - SERVER_NAME=Raspiheim
      - WORLD_NAME=Raspiworld
      - SERVER_PASS=Raspipass
      - PUBLIC=0
      - UPDATE=false
    ports:
      - "2456:2456/udp"
      - "2457:2457/udp"
    volumes:
      - "./valheim/data:/data"
      - "./valheim/server:/valheim"
    restart: unless-stopped

 

5. Run the following command to pull the image and run the container:

$ docker compose up -d

 

 

I think this is it for setting this up. I'll have to try this later.

Link to comment
Share on other sites

Link to post
Share on other sites

Just fired it up to see if it still work, should be perfectly fine.
I'd still recommend installing docker via the official documentation, getting compose with it and so on, assigning groups correctly so you don't have to run it via sudo, etc.

Does compose recognise the docker-compose.yml in a subfolder? I always thought it would have to be saved in the home directory.

Have fun and please leave a post about how it works for you! 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, Arokan said:

Does compose recognise the docker-compose.yml in a subfolder? I always thought it would have to be saved in the home directory.

docker-compose just searches the current directory for the docker-compose.yml file
You can put it in a subfolder, but it just means that you have to cd there first every time before running docker-compose

Link to comment
Share on other sites

Link to post
Share on other sites

On 7/19/2022 at 7:52 PM, Arokan said:

I'd still recommend installing docker via the official documentation, getting compose with it and so on

Updated my docker installation instructions to include docker without sudo. The docker installation script I included is provided from Docker itself, it's a convenience script which installs everything docker including Docker Compose V2.

 

It runs great, thank you so much 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

  • 5 months later...

Is this docker image still supported? If so is there a way to enable a crossplay?

Link to comment
Share on other sites

Link to post
Share on other sites

Wait...I can use my rasberry pi as a server? omgoodness, gonna try this out, 😆somany neat uses 

                          Ryzen 5800X3D(Because who doesn't like a phat stack of cache?) GPU - 7700Xt

                                                           X470 Strix f gaming, 32GB Corsair vengeance, WD Blue 500GB NVME-WD Blue2TB HDD, 700watts EVGA Br

 ~Extra L3 cache is exciting, every time you load up a new game or program you never know what your going to get, will it perform like a 5700x or are we beating the 14900k today? 😅~

Link to comment
Share on other sites

Link to post
Share on other sites

Yes, this is still supported.
I tried to implement Crossplay but apparently, it has some issues on linux-servers here and there; at least that's what a reddit-guy told me.

BepInEx is also not yet supported, but I'm going to continue working on that in April.

The latest version should still work.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...
On 1/19/2023 at 5:12 PM, Arokan said:

Yes, this is still supported.
I tried to implement Crossplay but apparently, it has some issues on linux-servers here and there; at least that's what a reddit-guy told me.

BepInEx is also not yet supported, but I'm going to continue working on that in April.

The latest version should still work.

I had to make an account just to give you a big thank you for this!

 

I'm not a linux genious, but try to learn more each day and this got me to get into docker.

 

I had a Valheim server running natively on my rpi4 8gb but the lag was unbearable, and the headache of getting it to play with box86 and 64 was, frustrating to say the least, steamclient.so still gives me nightmares. xD

So again, THANK YOU FOR THIS!

 

I invested in an SSD usb stick that is about 4x faster than a sandisk usb3.1 stick (yes, I tested it, and it actually is about 4x faster), and that helped with the save times, although it is still WAY slower than running it on an x64 server. I don't think the bottleneck is the storage but rather the usb interface on the rpi.

 

As I said this is the first time I used docker for anything. I got it to work, but I didn't use the docker-compose, but it works anyway!

But figured I should probably fix that and restart my server.
So, I tried to google this and it's confusing to me. WHERE should I put the docker-compose.yaml file? I figure in the "path/to/valheim" directory I state in the docker start command?

As of now I just saved the docker start command in a script. What I can't figure out is what the difference is? All data in the yaml file is also in the start command, why do I need the yaml file at all? And why does it work without me ever running a compose?

I could probably find this information on another forum but I really felt like I had to give you a big thank you.

Link to comment
Share on other sites

Link to post
Share on other sites

The difference is only in management. Compose is a little cleaner imho, you have everything in one file if you're running several containers (I have ~20 now) and it's easier to keep updated and so on.

Normally you have one docker-compose.yml in your home directory, but you can put it anywhere you want. Docker-compose uses the file in your current directory unless you tell it otherwise.

The saving-time problem get bigger as your world grows. My save-file is now about 100MB and it takes about 30-60s to save. Valheim fails to respond several times somewhere in between but disconnects rarely happen within that time, to me at least.
The bigger problem lies in unity when it tries to offload "0" things to save RAM. This somehow causes instant disconnects for all players, I don't quite get why. I'm thinking about recommending an 8GB pi if people want to use it for big worlds.

Thanks for using it and your kind words! 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...
On 2/3/2023 at 7:16 PM, Arokan said:

The difference is only in management. Compose is a little cleaner imho, you have everything in one file if you're running several containers (I have ~20 now) and it's easier to keep updated and so on.

Normally you have one docker-compose.yml in your home directory, but you can put it anywhere you want. Docker-compose uses the file in your current directory unless you tell it otherwise.

The saving-time problem get bigger as your world grows. My save-file is now about 100MB and it takes about 30-60s to save. Valheim fails to respond several times somewhere in between but disconnects rarely happen within that time, to me at least.
The bigger problem lies in unity when it tries to offload "0" things to save RAM. This somehow causes instant disconnects for all players, I don't quite get why. I'm thinking about recommending an 8GB pi if people want to use it for big worlds.

Thanks for using it and your kind words! 🙂

Oooooooh, so it's only ONE yaml file for ALL containers you run? THAT would explain my confusion.

I run it on an 8gb model, and the memory is never completely utilized, and my swapfile (increased size, just in case) is also VERY rarely used.

The ssd usb stick really helped though, 25mb/s vs 100mb/s, the savefile is about 100mb, simple math.

Updating the server with the argument set to true also works (did it with the latest update), BUT, you have to let it update, then stop the server and then run again with update false or it won't start. Don't remember where it freezes, but you are probably already aware of this.

docker logs -f raspiheim 🙂

 

We never experienced any dc:s, used the server for a whole playthrough with a friend, the lag-spikes caused, ehem, some incidents where the game froze for one person, and when it came back, "you are dead" (Queen vs me = 3-1) 😕 But we KNEW that was a risk, and we are pretty chill so yeah, it worked just fine and we could both play separately doing some of the grinding separately. And if you play solo on the server, there is ZERO problems, but then again, why have a dedicated server if you play solo you may ask, BECAUSE IT'S FKN COOL, THAT'S WHY,, SHUT UP.... xD

The server will rest until the next big update, hope you have the will to keep working on this project so I hopefully will be able to use it for the continuation of me and my friends valheim adventure.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×