joshhsoj1902 / linuxgsm-docker

MIT License
17 stars 5 forks source link

How to keep server saves/config? #161

Open InfernoZeus opened 3 years ago

InfernoZeus commented 3 years ago

I've been trying to use the example docker-compose files that you've got in this repository, but it's not clear to me how this preserves the save files and configuration for the game? (I'm trying to run Valheim, but I don't think it's a game specific question.) The only volume seems to be one for Log files, although even that wasn't working (I had to change from logs to log).

Are there some other paths/volumes I could create so that they outlive the lifetime of the container created by docker-compose?

joshhsoj1902 commented 3 years ago

@InfernoZeus I apologize that that isn't something that's more cleat in the compose files.

I'm actually working on updating all the examples so that they do save things by default.

https://github.com/joshhsoj1902/linuxgsm-docker/pull/160

The updated compose file will look something like this:

version: '3.1'
services:
  valheim:
    image: joshhsoj1902/linuxgsm-docker:latest
    ports:
      - 2456:2456/tcp
      - 2456:2456/udp
    environment:
      - LGSM_GAMESERVERNAME=vhserver
      - LGSM_SERVERNAME="My Game Name"
      - LGSM_UPDATEINSTALLSKIP=UPDATE
      - LGSM_PORT=2456
      # World Name
      - LGSM_GAMEWORLD
      # Private=0 Public=1
      - LGSM_PUBLIC=1

    # https://docs.docker.com/compose/compose-file/compose-file-v3/#volumes
    volumes:
      - serverfiles:/home/linuxgsm/linuxgsm/serverfiles

But that only half solves your problem, It will save all the serverfiles (and in theory the save files) into a docker volume called valheim_serverfiles. The data will survive across restarts, but the data is still hard to access if you needed wanted to access the save files directly.

Another option is to mount a local folder and have the server files written there. There is some details here on the different ways volumes can be mounted https://docs.docker.com/compose/compose-file/compose-file-v3/#volumes, But the simple suggestion is try something like this:

    volumes:
      - /local/path/where/you/want/to/save:/home/linuxgsm/linuxgsm/serverfiles

Years ago doing a local mount like that could cause some file permission issues if you were using docker on windows, I don't know if that's still the case.

joshhsoj1902 commented 3 years ago

I just updated the main Readme document https://github.com/joshhsoj1902/linuxgsm-docker/blob/0.9.0/README.md

And I updated the valheim compose file https://github.com/joshhsoj1902/linuxgsm-docker/blob/0.9.0/examples/docker-compose.valheim.yml

InfernoZeus commented 3 years ago

@joshhsoj1902 Really appreciate the quick help on this. No need to apologise!

I'm aware of how Docker works, and the distinction between named volumes and local folders, but I just couldn't work out which path inside the container I should be targeting. I'll give your new version a go :+1: