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.95k stars 272 forks source link

Volume Mapping with Docker-Compose #60

Closed joshaspinall closed 3 years ago

joshaspinall commented 3 years ago

Hello, I am looking to run up a server using your Container, firstly Kudos for the detailed instructions. As I am familiar and already run several containers from a docker-compose file, I opted to run the server this way. However, the volume mounts do not appear to work, and as such there is no persistence of files, and does not pull in my existing world. I am not sure if this is not supported when running this way? I have successfully used multiple services via a similar configuration. Help/input appreciated, and keep up the good work!

Updated to add: Executing inside the Container shows a different set of files in the Config folder, presumably those that are created by the Server as it starts.

Docker Compose snippet included below. valheim: image: lloesche/valheim-server container_name: valheim-serv ports: - 2456-2458:2456-2458/udp environment: - SERVER_NAME=[servername] - WORLD_NAME=[worldname] - SERVER_PASS=[password] volumes: - /valheim/config:/config - /valheim/backups:/config/backups - /valheim/worlds:/config/worlds - /valheim/server:/opt/valheim_dl restart: unless-stopped

lloesche commented 3 years ago

However, the volume mounts do not appear to work

What does a mount inside the container show?

Toucan-Sam commented 3 years ago

Mount volumes works perfectly fine with this container. You have added a ton of mounts that you probably don't need. You're mounting each individual folder directly and they're all in exactly the same positions they would be if you didn't mount them all one at a time.

Try this instead and make sure the /valheim folder exists before you start the container.

---
version: '3'
services:
   valheim:
      image: lloesche/valheim-server
      container_name: valheim-serv
      ports:
         - 2456-2458:2456-2458/udp
      environment:
         - SERVER_NAME=[servername]
         - WORLD_NAME=[worldname]
         - SERVER_PASS=[password]
      volumes:
         - /valheim:/config
      restart: unless-stopped
joshaspinall commented 3 years ago

@lloesche Output of mount shown below. Of note I also don't see a mount for /opt/valheim_dl. The volume is empty outside of the container as well. Inside the Container shows all exptected files in both there and /config. Removing all but the /config mount is the same.

@Toucan-Sam I have simplified my /config mountings as described, the issue remains. The folder exists, but contains my /worlds folder copied from my desktop machine.

Do I need to start the server with the folder mount empty, stop it, then move the files in and restart?

root@45d540a00ea4:/# mount overlay on / type overlay (rw,relatime,lowerdir=/var/lib/docker/overlay2/l/V5I34DEQFCEIVSKJ3M4HUUTAKK:/var/lib/docker/overlay2/l/USK5DN3QBBRRABX4Q7WCSTQF4N:/var/lib/docker/overlay2/l/GLBA3AVUIQ3R6ROZ77NPOWB7VJ:/var/lib/docker/overlay2/l/4M33THL7GXJL4LEWU4KY2ROJ4F:/var/lib/docker/overlay2/l/I3SKUO2OX6GWBDBDP6SII3EBY4:/var/lib/docker/overlay2/l/CIYI6G35HK32CUB3USKXO5OJEB:/var/lib/docker/overlay2/l/GOFZ3IV2NZMYDEJZDPLW6BCKW2,upperdir=/var/lib/docker/overlay2/b69591a03ebbedf7fe919b83e032ae63d6d3ce104d9326a520747f80ca6117d6/diff,workdir=/var/lib/docker/overlay2/b69591a03ebbedf7fe919b83e032ae63d6d3ce104d9326a520747f80ca6117d6/work) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev type tmpfs (rw,nosuid,size=65536k,mode=755) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666) sysfs on /sys type sysfs (ro,nosuid,nodev,noexec,relatime) tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (ro,nosuid,nodev,noexec,relatime,xattr,name=systemd) cgroup on /sys/fs/cgroup/memory type cgroup (ro,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/blkio type cgroup (ro,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (ro,nosuid,nodev,noexec,relatime,cpu,cpuacct) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (ro,nosuid,nodev,noexec,relatime,net_cls,net_prio) cgroup on /sys/fs/cgroup/rdma type cgroup (ro,nosuid,nodev,noexec,relatime,rdma) cgroup on /sys/fs/cgroup/devices type cgroup (ro,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/pids type cgroup (ro,nosuid,nodev,noexec,relatime,pids) cgroup on /sys/fs/cgroup/cpuset type cgroup (ro,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/perf_event type cgroup (ro,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/freezer type cgroup (ro,nosuid,nodev,noexec,relatime,freezer) mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime) shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=65536k) /dev/mapper/watcher--vg-root on /config type ext4 (rw,relatime,errors=remount-ro) /dev/mapper/watcher--vg-root on /opt/valheim_dl type ext4 (rw,relatime,errors=remount-ro) /dev/mapper/watcher--vg-root on /etc/resolv.conf type ext4 (rw,relatime,errors=remount-ro) /dev/mapper/watcher--vg-root on /etc/hostname type ext4 (rw,relatime,errors=remount-ro) /dev/mapper/watcher--vg-root on /etc/hosts type ext4 (rw,relatime,errors=remount-ro) proc on /proc/bus type proc (ro,relatime) proc on /proc/fs type proc (ro,relatime) proc on /proc/irq type proc (ro,relatime) proc on /proc/sys type proc (ro,relatime) proc on /proc/sysrq-trigger type proc (ro,relatime) tmpfs on /proc/acpi type tmpfs (ro,relatime) tmpfs on /proc/kcore type tmpfs (rw,nosuid,size=65536k,mode=755) tmpfs on /proc/keys type tmpfs (rw,nosuid,size=65536k,mode=755) tmpfs on /proc/timer_list type tmpfs (rw,nosuid,size=65536k,mode=755) tmpfs on /proc/sched_debug type tmpfs (rw,nosuid,size=65536k,mode=755) tmpfs on /sys/firmware type tmpfs (ro,relatime)

Toucan-Sam commented 3 years ago

I would always start with empty mount points, yes. Once you know what the data structure looks like, pop your stuff in the right place, set the right permissions if not running as root, and should be good to go.

joshaspinall commented 3 years ago

Brace for admission of guilt......

I hadn't mounted my ZFS dataset correctly, so instead of mounting the /valheim folder on the ZFS dataset, it was helpfully making a new folder on the boot under / disk.

Problem solved, up and running now. Many Thanks for the responses!

Pompeoar commented 3 years ago

I'm doing something very similar - trying to deploy this using az webapp. I keep getting this error:

2021-02-21T16:10:57.541Z INFO  - Starting multi-container app..
2021-02-21T16:10:57.542Z ERROR - Exception in multi-container config parsing: Exception: System.FormatException, Msg: Input string was not in a correct format.

My yaml looks almost exactly the same as yours. I had a lot more env variables but I've stripped it down to the bare minimum trying to figure this out. What am I missing?

version: "3.9"
services: 
  valheim: 
    image: lloesche/valheim-server
    volumes: 
      - ${WEBAPP_STORAGE_HOME}/valheim:/config
    ports: 
      - "2456-2458:2456-2458/udp"
    environment: 
      - SERVER_NAME=myserver
      - SERVER_PASS=mypassword
      - SERVER_PUBLIC=1
      - WORLD_NAME=my world name

FWIW I literally just did the docker-compose tutorial to try this approach today so I'm very new to this.

EDIT: Changed to this after learning I needed to create storage, create file share, mount file share to app service

version: "3.9"
services: 
  valheim: 
    image: lloesche/valheim-server
    volumes: 
      - valheim:/config
    ports: 
      - "2456-2458:2456-2458/udp"
    environment: 
      SERVER_NAME: myserver
      SERVER_PASS: mysecret
      SERVER_PUBLIC: 1
      WORLD_NAME: world name
    restart: unless-stopped

Still the same error though (just don't need that {WEBAPP_STORAGE_HOME} anymore

joshaspinall commented 3 years ago

@Pompeoar I'm by no means a docker-compose expert, but I suggest to remove the quotation marks around your port mapping.

From this: - "2456-2458:2456-2458/udp" To this: - 2456-2458:2456-2458/udp

Also there is no leading slash in your volume mount - valheim:/config, I suspect it should be - /valheim:/config. This assumes you have the /valheim on your system, but I have 0 experience with Azure, YMMW. Good luck!

Pompeoar commented 3 years ago

@joshaspinall Hey thanks for taking the time to reply and being so nice about it.

I did try with and without quotations, and even listing each port out. Eventually yanking off the UDP worked. I think it comes down to azure app service not processing the docker-compose.yml correctly because the docker-compose documentation shows that's clearly a valid way of doing it.

For anyone else that finds this, I ended up using ACI. I don't think that's the correct solution for something as long living as a game server, but app service with a container just kept throwing up new roadblocks.

Thanks for making this container!