mschnitzer / ark-survival-ascended-linux-container-image

A docker/podman container that is able to run an ARK: Survival Ascended on a Linux host.
69 stars 13 forks source link

Custom volume paths #64

Closed Kivarnis closed 2 months ago

Kivarnis commented 2 months ago

Unless I am simply inept (Possible, only just learning docker) there is no way to set your own volume paths so that data goes where you want it to go. I need to be able to specify where all the data is stored.

mschnitzer commented 2 months ago

It is possible to define your own paths, but let me ask you why you want a different path? Multiple disks/NFS mounts?

Here's an example how it could look like:

version: "3.3"
services:
  asa-server-1:
    container_name: asa-server-1
    hostname: asa-server-1
    entrypoint: "/usr/bin/start_server"
    user: gameserver
    image: "mschnitzer/asa-linux-server:latest"
    environment:
      - ASA_START_PARAMS=TheIsland_WP?listen?Port=7777?RCONPort=27020?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared"
      - ENABLE_DEBUG=0
    ports:
      # Game port for player connections through the server browser
      - 0.0.0.0:7777:7777/udp
      # RCON port for remote server administration
      - 0.0.0.0:27020:27020/tcp
    depends_on:
      - set-permissions-1
    volumes:
      - steam-1:/home/gameserver/Steam:rw
      - steamcmd-1:/home/gameserver/steamcmd:rw
      - /my/new/path/server-files-1:/home/gameserver/server-files:rw
      - cluster-shared:/home/gameserver/cluster-shared:rw
      - /etc/localtime:/etc/localtime:ro
    networks:
      asa-network:
  set-permissions-1:
    entrypoint: "/bin/bash -c 'chown -R 25000:25000 /steam ; chown -R 25000:25000 /steamcmd ; chown -R 25000:25000 /server-files ; chown -R 25000:25000 /cluster-shared'"
    user: root
    image: "opensuse/leap"
    volumes:
      - steam-1:/steam:rw
      - steamcmd-1:/steamcmd:rw
      - /my/new/path/server-files-1:/server-files:rw
      - cluster-shared:/cluster-shared:rw
#  asa-server-2:
#    container_name: asa-server-2
#    hostname: asa-server-2
#    entrypoint: "/usr/bin/start_server"
#    user: gameserver
#    image: "mschnitzer/asa-linux-server:latest"
#    environment:
#      - ASA_START_PARAMS=ScorchedEarth_WP?listen?Port=7778?RCONPort=27021?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared"
#    ports:
#      # Game port for player connections through the server browser
#      - 0.0.0.0:7778:7778/udp
#      # RCON port for remote server administration
#      - 0.0.0.0:27021:27021/tcp
#    depends_on:
#      - set-permissions-2
#    volumes:
#      - steam-2:/home/gameserver/Steam:rw
#      - steamcmd-2:/home/gameserver/steamcmd:rw
#      - server-files-2:/home/gameserver/server-files:rw
#      - cluster-shared:/home/gameserver/cluster-shared:rw
#      - /etc/localtime:/etc/localtime:ro
#    networks:
#      asa-network:
#  set-permissions-2:
#    entrypoint: "/bin/bash -c 'chown -R 25000:25000 /steam ; chown -R 25000:25000 /steamcmd ; chown -R 25000:25000 /server-files ; chown -R 25000:25000 /cluster-shared'"
#    user: root
#    image: "opensuse/leap"
#    volumes:
#      - steam-2:/steam:rw
#      - steamcmd-2:/steamcmd:rw
#      - server-files-2:/server-files:rw
#      - cluster-shared:/cluster-shared:rw
volumes:
  cluster-shared:
  steam-1:
  steamcmd-1:
#  steam-2:
#  steamcmd-2:
#  server-files-2:
networks:
  asa-network:
    attachable: true
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: 'asanet'

The example assumes you only care about the server-files but the Steam installation can remain at /var/lib/docker/volumes - doesn't take too much space either.

Kivarnis commented 2 months ago

Awesome thank you. And yes i have something like 15 disks in this server plus it does a fair few differing tasks for me which requires a bit of organization to keep track of what is where for my own sanity.

mschnitzer commented 2 months ago

Alright, can we close this issue then? Have your questions been answered?

Kivarnis commented 2 months ago

Yes, but for the sake of OCD, can I move all the volumes this way? My attempt to do so ran into permission issues in a hurry. It's ultimately fine if not but I am slightly OCD when it comes to organizing everything.

Kivarnis commented 2 months ago

Yes, but for the sake of OCD, can I move all the volumes this way? My attempt to do so ran into permission issues in a hurry. It's ultimately fine if not but I am slightly OCD when it comes to organizing everything.

Actually no, trying this resulted in the following.

Success! App '2430930' fully installed. mkdir: cannot create directory '/home/gameserver/server-files/steamapps': Permission denied cp: cannot create directory '/home/gameserver/server-files/steamapps/compatdata/2430930': No such file or directory Starting the ARK: Survival Ascended dedicated server... Start parameters: TheIsland_WP?listen?Port=7777?RCONPort=27020?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared" /usr/bin/start_server: line 49: cd: /home/gameserver/server-files/ShooterGame/Binaries/Win64: No such file or directory Traceback (most recent call last): File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton", line 1903, in g_session.init_session(sys.argv[1] != "runinprefix") File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton", line 1683, in init_session g_compatdata.setup_prefix() File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton", line 776, in setup_prefix with self.prefix_lock: File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/filelock.py", line 323, in enter self.acquire() File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/filelock.py", line 271, in acquire self._acquire() File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/filelock.py", line 384, in _acquire fd = os.open(self._lock_file, open_mode) FileNotFoundError: [Errno 2] No such file or directory: '/home/gameserver/server-files/steamapps/compatdata/2430930/pfx.lock'

Kivarnis commented 2 months ago

Yes, but for the sake of OCD, can I move all the volumes this way? My attempt to do so ran into permission issues in a hurry. It's ultimately fine if not but I am slightly OCD when it comes to organizing everything.

Actually no, trying this resulted in the following.

Success! App '2430930' fully installed. mkdir: cannot create directory '/home/gameserver/server-files/steamapps': Permission denied cp: cannot create directory '/home/gameserver/server-files/steamapps/compatdata/2430930': No such file or directory Starting the ARK: Survival Ascended dedicated server... Start parameters: TheIsland_WP?listen?Port=7777?RCONPort=27020?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared" /usr/bin/start_server: line 49: cd: /home/gameserver/server-files/ShooterGame/Binaries/Win64: No such file or directory Traceback (most recent call last): File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton", line 1903, in g_session.init_session(sys.argv[1] != "runinprefix") File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton", line 1683, in init_session g_compatdata.setup_prefix() File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton", line 776, in setup_prefix with self.prefix_lock: File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/filelock.py", line 323, in enter self.acquire() File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/filelock.py", line 271, in acquire self._acquire() File "/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/filelock.py", line 384, in _acquire fd = os.open(self._lock_file, open_mode) FileNotFoundError: [Errno 2] No such file or directory: '/home/gameserver/server-files/steamapps/compatdata/2430930/pfx.lock'

This may be my error, missed the change near the end, trying now, but also noted this following error, it may not matter but just in case.

/home/gameserver/steamcmd/steamcmd.sh: line 39: ulimit: open files: cannot modify limit: Operation not permitted

Kivarnis commented 2 months ago

Same error, no change, server fails to start.

mschnitzer commented 2 months ago

What's the path you want the server to be installed at? I'll make an example of a docker-compose.yml file then.

Kivarnis commented 2 months ago

/home/kiva/ArkAscended/(folder-here)

mschnitzer commented 2 months ago

So please use this docker-compose.yml instead:

version: "3.3"
services:
  asa-server-1:
    container_name: asa-server-1
    hostname: asa-server-1
    entrypoint: "/usr/bin/start_server"
    user: gameserver
    image: "mschnitzer/asa-linux-server:latest"
    environment:
      - ASA_START_PARAMS=TheIsland_WP?listen?Port=7777?RCONPort=27020?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared"
      - ENABLE_DEBUG=0
    ports:
      # Game port for player connections through the server browser
      - 0.0.0.0:7777:7777/udp
      # RCON port for remote server administration
      - 0.0.0.0:27020:27020/tcp
    depends_on:
      - set-permissions-1
    volumes:
      - /home/kiva/ArkAscended/steam-1:/home/gameserver/Steam:rw
      - /home/kiva/ArkAscended/steamcmd-1:/home/gameserver/steamcmd:rw
      - /home/kiva/ArkAscended/server-files-1:/home/gameserver/server-files:rw
      - /home/kiva/ArkAscended/cluster-shared:/home/gameserver/cluster-shared:rw
      - /etc/localtime:/etc/localtime:ro
    networks:
      asa-network:
  set-permissions-1:
    entrypoint: "/bin/bash -c 'chown -R 25000:25000 /steam ; chown -R 25000:25000 /steamcmd ; chown -R 25000:25000 /server-files ; chown -R 25000:25000 /cluster-shared'"
    user: root
    image: "opensuse/leap"
    volumes:
      - /home/kiva/ArkAscended/steam-1:/steam:rw
      - /home/kiva/ArkAscended/steamcmd-1:/steamcmd:rw
      - /home/kiva/ArkAscended/server-files-1:/server-files:rw
      - /home/kiva/ArkAscended/cluster-shared:/cluster-shared:rw
#  asa-server-2:
#    container_name: asa-server-2
#    hostname: asa-server-2
#    entrypoint: "/usr/bin/start_server"
#    user: gameserver
#    image: "mschnitzer/asa-linux-server:latest"
#    environment:
#      - ASA_START_PARAMS=ScorchedEarth_WP?listen?Port=7778?RCONPort=27021?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared"
#    ports:
#      # Game port for player connections through the server browser
#      - 0.0.0.0:7778:7778/udp
#      # RCON port for remote server administration
#      - 0.0.0.0:27021:27021/tcp
#    depends_on:
#      - set-permissions-2
#    volumes:
#      - steam-2:/home/gameserver/Steam:rw
#      - steamcmd-2:/home/gameserver/steamcmd:rw
#      - server-files-2:/home/gameserver/server-files:rw
#      - cluster-shared:/home/gameserver/cluster-shared:rw
#      - /etc/localtime:/etc/localtime:ro
#    networks:
#      asa-network:
#  set-permissions-2:
#    entrypoint: "/bin/bash -c 'chown -R 25000:25000 /steam ; chown -R 25000:25000 /steamcmd ; chown -R 25000:25000 /server-files ; chown -R 25000:25000 /cluster-shared'"
#    user: root
#    image: "opensuse/leap"
#    volumes:
#      - steam-2:/steam:rw
#      - steamcmd-2:/steamcmd:rw
#      - server-files-2:/server-files:rw
#      - cluster-shared:/cluster-shared:rw
#  steam-2:
#  steamcmd-2:
#  server-files-2:
networks:
  asa-network:
    attachable: true
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: 'asanet'

Please run the following commands before you execute any docker or docker-compose commands:

mkdir -p /home/kiva/ArkAscended/steam-1
mkdir -p /home/kiva/ArkAscended/steamcmd-1
mkdir -p /home/kiva/ArkAscended/server-files-1
mkdir -p /home/kiva/ArkAscended/cluster-shared

This creates the directories used by docker.

Now delete the existing container:

docker stop-asa-server-1
docker rm -f asa-server-1

This stops and deletes any existing container.

Now run docker-compose up -d and it should make use of your volumes.

Kivarnis commented 2 months ago

Same exact error, sadly.

sudo docker logs -f asaserver --2024-04-30 02:59:16-- https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz Resolving steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net)... 23.204.115.168, 23.204.115.180 Connecting to steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net)|23.204.115.168|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 2428561 (2.3M) [application/octet-stream] steamcmd_linux.tar.gz: Permission denied

Cannot write to 'steamcmd_linux.tar.gz' (Permission denied). tar (child): steamcmd_linux.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now /usr/bin/start_server: line 17: ./steamcmd.sh: No such file or directory mkdir: cannot create directory '/home/gameserver/Steam/compatibilitytools.d': Permission denied tar: /home/gameserver/Steam/compatibilitytools.d: Cannot open: No such file or directory tar: Error is not recoverable: exiting now mkdir: cannot create directory '/home/gameserver/server-files/steamapps': Permission denied cp: cannot stat '/home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/files/share/default_pfx': No such file or directory Starting the ARK: Survival Ascended dedicated server... Start parameters: TheIsland_WP?listen?Port=7777?RCONPort=27020?RCONEnabled=True -WinLiveMaxPlayers=50 -clusterid=default -ClusterDirOverride="/home/gameserver/cluster-shared" /usr/bin/start_server: line 49: cd: /home/gameserver/server-files/ShooterGame/Binaries/Win64: No such file or directory /usr/bin/start_server: line 50: /home/gameserver/Steam/compatibilitytools.d/GE-Proton8-21/proton: No such file or directory

Kivarnis commented 2 months ago

Worth noting defaults work, but not for my personal use case.

mschnitzer commented 2 months ago

Can you please run ls -l /home/kiva/ArkAscended/ on the host system, I just want to see what permissions the directories have.

Kivarnis commented 2 months ago
drwxr-xr-x. 2 kiva kiva 4096 Apr 30 02:57 cluster-shared
-rw-r--r--. 1 kiva kiva 3014 Apr 30 02:58 compose.yaml
drwxr-xr-x. 2 kiva kiva 4096 Apr 30 02:57 server-files-1
drwxr-xr-x. 2 kiva kiva 4096 Apr 30 02:57 steam-1
drwxr-xr-x. 2 kiva kiva 4096 Apr 30 02:57 steamcmd-1

There you are

mschnitzer commented 2 months ago

It doesn't work because the container needs to operate as uid 25000 and gid 25000. In your case these folders are still owned by kiva:kiva, which is wrong. Normally the compose file takes care of setting the permissions, but that didn't happen for some reason.

Can you please delete the container docker rm -f asa-server-1 again and run docker-compose up -d again?

If you encounter the same error again, please show me the content of the docker-compose.yml of the directory where you're running docker-compose up -d from.

Kivarnis commented 2 months ago

I have been doing this, and the file is literally the one you posted up verbatim minus changing name to asaserver instead of asa-server-1. I made the folders prior to running the compose file, should I not have?

mschnitzer commented 2 months ago

What happens now if you delete the container manually and run docker-compose up -d ? It should set the permissions correctly.

Kivarnis commented 2 months ago

As I said, I already do this when shutting it down. Every attempt has been entirely fresh.

mschnitzer commented 2 months ago

So are you executing docker-compose up -d in /home/kiva/ArkAscended/ or from somewhere else?

Kivarnis commented 2 months ago

Yes that is correct. Though oddly, mine requires sudo to work, I've never known why, perhaps this is the reason?

Kivarnis commented 2 months ago

Fixed the lack of running without sudo testing now.

Kivarnis commented 2 months ago

That worked, this can be closed, it was due to running under sudo.

mschnitzer commented 2 months ago

Glad it worked!