lloesche / valheim-server-docker

Valheim dedicated gameserver with automatic update, World backup, BepInEx and ValheimPlus mod support
https://hub.docker.com/r/lloesche/valheim-server
Apache License 2.0
1.93k stars 271 forks source link

After today's update (0.202.14 Hearth & Home), my world will not load #394

Closed Joeaculberson closed 3 years ago

Joeaculberson commented 3 years ago

Discussed in https://github.com/lloesche/valheim-server-docker/discussions/393

Originally posted by **Joeaculberson** September 16, 2021 I have a very basic setup on a linux server with pretty much all default settings. This is my first update since I started using this container. When I go to login into my world, the game drops me in a completely new world. I've tried coping the backup files into /etc/valheim/worlds, but it just overwrites them when I join the world (except the .old files). It's worth mentioning if I copy these files on to my local machine into C:\Users\\AppData\LocalLow\IronGate\Valheim\worlds, everything loads fine. If anyone knows how to fix this, I'd really appreciate it. Thanks!
ibex-are-goats commented 3 years ago

It's working for me, so my guess is that you're running into the outdated version bug. This docker is out of date on the official docker site. You need to use this now instead:

version: "3" services: valheim-server: image: ghcr.io/lloesche/valheim-server:latest

Joeaculberson commented 3 years ago

How do I update to the latest version on linux? Will have I have to delete my current container and create a new one? If so, could you walk me through the deletion process?

EDIT: How do I check which version I am using? I set this up maybe less than a month ago.

ibex-are-goats commented 3 years ago

How do I update to the latest version on linux?

Yeah with docker stuff you're supposed to have your important data safely retained outside of the container with the config file. Then, to update the container, you actually nuke the container and remake it. On my Synology NAS I do this according to the guides I read online: docker-compose -f /volume1/docker/docker-compose.yml pull docker-compose -f /volume1/docker/docker-compose.yml up -d

And that yml file I made by hand using the instructions in the valheim-server-docker github readme. In it, I had to change the container location from the official docker one to ghcr.io/lloesche/valheim-server:latest because apparently that's where the creator is updating it now.

lloesche commented 3 years ago

I don't think this has anything to do with the age of the container. I haven't played the game or updated the container on our own server in quite a while (as in since May or so) and just tested it and was able to just log in and it loaded our old world.

CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                                NAMES
0f8a154bbe38        lloesche/valheim-server:dev   "/usr/local/sbin/b..."   3 months ago        Up 3 months         80/tcp, 9001/tcp, 0.0.0.0:2456-2458->2456-2458/udp   valheim-server.service

REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.io/lloesche/valheim-server             dev                 a9582bfd3a6d        4 months ago        509 MB

The container will update valheim-server to the latest version automatically and there haven't been any substantial changes to the container since Jun 10th 2021. So whatever the reason it's loading into a new world the container age shouldn't be the issue.

lloesche commented 3 years ago

@ibex-are-goats good catch! I wasn't even aware Dockerhub isn't auto building the container anymore. When I log in they tell me that auto builds are only available to paying customers now. Since we've always built for both Dockerhub and Github container registry I'll just update all the docs to reference the Github image. Maybe I can set up a second workflow that'll push the image from Github to Dockerhub. Either way it's not related to this issue.

Joeaculberson commented 3 years ago

I was able to get my server back up and running. What I ended up doing was nuking my docker container and changing the last line of my docker run command to ghcr.io/lloesche/valheim-server:latest. Not sure if was related, but redoing everything worked. I'll keep an eye on it for the next update.

Here are the commands I ran to redo everything: sudo docker rm /valheim-server sudo docker run -d \ --name valheim-server \ --cap-add=sys_nice \ --stop-timeout 120 \ -p 2456-2457:2456-2457/udp \ -v $HOME/valheim-server/config:/config \ -v $HOME/valheim-server/data:/opt/valheim \ -e SERVER_NAME="server_name" \ -e WORLD_NAME="world_name" \ -e SERVER_PASS="my_password" \ -e ADMINLIST_IDS="ids" \ -e BACKUPS_MAX_AGE="7" \ -e DISCORD_WEBHOOK="myhook" \ -e VALHEIM_LOG_FILTER_CONTAINS_Spawned="Got character ZDOID from" \ -e ON_VALHEIM_LOG_FILTER_CONTAINS_Spawned='{ read l; l=${l//ZDOID from /}; l=${l// :/}; msg="Player $l spawned into the world"; curl -sfSL -X POST -H "Content-Type: application/json" -d "{\"username\":\"Valheim\",\"content\":\"$msg\"}" "$DISCORD_WEBHOOK"; }' \ ghcr.io/lloesche/valheim-server:latest

_(things like, server_name, worldname, etc are not actual values)

I got: docker: Error response from daemon: driver failed programming external connectivity on endpoint valheim-server (5d6762b7216433866cf2b8ac929af12855b5606dd53dcac14c6563900447d90b): Error starting userland proxy: listen udp 0.0.0.0:2457: bind: address already in use.

So I did this to resolve the issue: sudo lsof -i -P -n | grep port_number sudo kill -9 process_id

I also had to do: ip link delete docker0 sudo systemctl restart docker

Only then was I able to run the docker run command.

Not sure if any of this was entirely necessary, but it works and maybe it'll help someone else down the road. I appreciate the responses!

lloesche commented 3 years ago

The bind: address already in use would mean that there was still another valheim-server running - or at least something was bound on udp port 2457 which would very likely be valheim-server. Did you check with docker ps if the previous container was no longer running? The kill -9 might have stopped it. If it wasn't running and it still threw that bind message it's likely that Docker's networking got out of whack. Maybe the old userland proxy was still running and occupying that port.

That said none of these networking issues should be related to the server starting up with an empty world. Also none of the steps you described gives me any idea of what might have been the issue. As long as the WORLD_NAME corresponds to the .db file in the config directory the server should load up that world. Also it is important not to rename those files. We had reports where users tried to rename the .db file as well as change the WORLD_NAME to the same value and that didn't work. I believe the issue was that Valheim also stored that name inside of those files not just in the file name, but I don't remember the details.

Anyhow I'm glad it worked out!