使用 Docker 轻松管理 Palworld 服务端

发表于 更新于

前言

最近我制作了 Palworld 的 Docker 镜像,非专业用户仅需具备最基本的 Docker 安装经验即可轻松部署 Palworld 服务端。

前提

您的系统环境需安装 Docker 以及 Docker Compose。某些情况下你的服务器可能会不支持 Docker:

  1. 虚拟化类型。云服务器普遍基于虚拟化技术,说直白点就是虚拟机。某些虚拟化技术不支持 Docker,例如 OpenVZ 虚拟化出来的“容器”。虽然 OpenVZ 7 已经支持 Docker 了,但少部分不支持 Docker 的 OVZ 服务器仍然存在。
  2. 系统问题。因为某些原因,中文 Linux 运维生态有自己的“特色”,例如他们普遍崇尚用旧版本的 CentOS 作为服务器系统。在某些太旧的 CentOS 上 Docker 也不能很好的运行。

所以:如果你的服务器是 OVZ 容器并尝试运行 Docker 失败,请更换服务商产品类型(选择基于 Xen/KVM 的虚拟机)。如果你使用的是 CentOS,请直接重装为 Debian (12) 或 Ubuntu (22.04)。

如果你使用的是软路由,某些基于 OpenWrt 的国产固件也不能很好的运行 Docker。

在绝大部分情况下,你们购买的云服务器产品是没有 Docker 支持问题的。但据我所知,有一些人是在闲鱼、淘宝一类的场所购买云服务器,这些产品的质量参差不起,是极不可靠的。

过程

创建一个 palworld-server 文件夹,我们以此文件夹为工作目录进行后续操作。

如果你「整理困难症」犯了不知道应该把文件夹放哪儿,那我建议你在用户目录下创建一个 dockerapps 目录,然后在里边创建 palworld-server,即 dockerapps/palworld-server

palworld-server 文件夹下创建 docker-compose.yml 文件,内容如下:

version: "3"

services:
  main:
    image: hentioe/steamcmd:palworld-server
    ports:
      - "8211:8211/udp"
    command:
      - "EpicApp=PalServer"
    volumes:
      - ./steamapps:/home/steamcmd/steamapps
    restart: always

手动创建 steamapps 文件夹:mkdir -m 777 steamapps。运行命令 docker compose up -d 启动容器。

根据 docker-compose.yml 中的配置,我们将当前路径下的 steamapps 目录挂载到容器中。其实我们通常不用手动创建这类挂载到容器中的目录,但为了避免权限问题我们需要这样做(因为容器中启动的进程以 1000 作为 UID 运行)。

大功告成!

检查状态

容器启动后,首先会安装 Palworld 服务端。安装完成后自动启动。在启动前还会复制默认的配置文件。

运行 docker compose logs 命令查看容器的输出日志,可以查看启动进度。正常来讲你在最上面会看到 Steam 的一些输出,如:

palworld-server-main-1  | tid(11) burning pthread_key_t == 0 so we never use it
palworld-server-main-1  | Redirecting stderr to '/home/steamcmd/Steam/logs/stderr.txt'
palworld-server-main-1  | Logging directory: '/home/steamcmd/Steam/logs'
palworld-server-main-1  | [  0%] Checking for available updates...
palworld-server-main-1  | [----] Verifying installation...
palworld-server-main-1  | [  0%] Downloading update...
palworld-server-main-1  | [  0%] Checking for available updates...
palworld-server-main-1  | [----] Download complete.
palworld-server-main-1  | [----] Extracting package...
palworld-server-main-1  | [----] Extracting package...
palworld-server-main-1  | [----] Extracting package...
palworld-server-main-1  | [----] Extracting package...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Installing update...
palworld-server-main-1  | [----] Cleaning up...
palworld-server-main-1  | [----] Update complete, launching Steamcmd...
palworld-server-main-1  | tid(23) burning pthread_key_t == 0 so we never use it
palworld-server-main-1  | Redirecting stderr to '/home/steamcmd/Steam/logs/stderr.txt'
palworld-server-main-1  | Logging directory: '/home/steamcmd/Steam/logs'
palworld-server-main-1  | [  0%] Checking for available updates...
palworld-server-main-1  | [----] Verifying installation...
palworld-server-main-1  | Steam Console Client (c) Valve Corporation - version 1705108307
palworld-server-main-1  | -- type 'quit' to exit --
palworld-server-main-1  | Loading Steam API...OK
palworld-server-main-1  | 
palworld-server-main-1  | Connecting anonymously to Steam Public...OK
palworld-server-main-1  | Waiting for client config...OK

Waiting for client config...OK 这个输出后,可能要等待好一会儿。一般一两分钟后会看到后续输出:

palworld-server-main-1  | Waiting for user info...OK
palworld-server-main-1  |  Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
palworld-server-main-1  |  Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
palworld-server-main-1  |  Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
palworld-server-main-1  |  Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 0.00 (0 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 0.19 (4194304 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 0.93 (20971520 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 3.24 (72732716 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 6.71 (150830167 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 13.77 (309573239 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 21.25 (477638978 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 24.02 (539935014 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 26.93 (605506161 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 28.68 (644696624 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 31.65 (711422364 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 33.84 (760847427 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 35.99 (809017884 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 38.38 (862810541 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 40.42 (908686112 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 42.76 (961196474 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 45.18 (1015660061 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 48.07 (1080527900 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 50.38 (1132560383 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 52.67 (1184074647 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 55.14 (1239604776 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 57.47 (1292033087 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 60.06 (1350277825 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 63.14 (1419407318 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 66.18 (1487800135 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 69.54 (1563397184 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 72.37 (1626971781 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 74.88 (1683358670 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 78.69 (1769041757 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 82.64 (1857701663 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 86.63 (1947489175 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 89.22 (2005709782 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 92.25 (2073765257 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 95.43 (2145303639 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 98.01 (2203280809 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 98.56 (2215766741 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 98.75 (2219961045 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 98.98 (2225203925 / 2248045559)
palworld-server-main-1  |  Update state (0x61) downloading, progress: 99.57 (2238282023 / 2248045559)
palworld-server-main-1  |  Update state (0x81) verifying update, progress: 28.13 (632458456 / 2248045559)
palworld-server-main-1  | Success! App '2394010' fully installed.

这里的 Success! App '2394010' fully installed. 表示安装 Palworld 服务端成功。还可以发现 Steam 在下载 Palworld 服务端时,会输出百分比进度。因为可靠的 CDN,通常速度非常快。

然后是 Palworld 启动的输出:

palworld-server-main-1  | Copying default config file...
palworld-server-main-1  | dlopen failed trying to load:
palworld-server-main-1  | steamclient.so
palworld-server-main-1  | with error:
palworld-server-main-1  | steamclient.so: cannot open shared object file: No such file or directory
palworld-server-main-1  | Shutdown handler: initalize.
palworld-server-main-1  | [S_API] SteamAPI_Init(): Loaded '/home/steamcmd/.local/share/Steam/steamcmd/linux64/steamclient.so' OK.  (First tried local 'steamclient.so')
palworld-server-main-1  | - Existing per-process limit (soft=1073741816, hard=1073741816) is enough for us (need only 1073741816)
palworld-server-main-1  | Increasing per-process limit of core file size to infinity.
palworld-server-main-1  | - Existing per-process limit (soft=18446744073709551615, hard=18446744073709551615) is enough for us (need only 18446744073709551615)
palworld-server-main-1  | CAppInfoCacheReadFromDiskThread took 2 milliseconds to initialize
palworld-server-main-1  | Setting breakpad minidump AppID = 2394010
palworld-server-main-1  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-server-main-1  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-server-main-1  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-server-main-1  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.

看到 [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded. 即表示启动成功。

修改配置

文件 steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini 是我们的服务端世界配置。我的镜像在启动时,会自动检测配置是否存在或者是否为空,如果是则会复制一份默认配置过来。所以这个文件是有值的,所有配置项全是默认值。

默认配置内容如下:

; This configuration file is a sample of the default server settings.
; Changes to this file will NOT be reflected on the server.
; To change the server settings, modify Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.
[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName="Default Palworld Server",ServerDescription="",AdminPassword="",ServerPassword="",PublicPort=8211,PublicIP="",RCONEnabled=False,RCONPort=25575,Region="",bUseAuth=True,BanListURL="https://api.palworldgame.com/api/banlist.txt")
注意,实际上我并没有自以为是的为你们“生成”一个默认配置。其实在 Palworld 服务端安装好以后,会自带的一个默认配置文件,路径在 steamapps/common/PalServer/DefaultPalWorldSettings.ini。而我为大家生成的世界配置的内容就来源于此,否则它是空的。

一些修改示例:

  • ServerName 的值设置为 Dockerized Palworld Server,会看到世界的名称变了。
  • ServerPassword 的值设置为一个密码,会发现进入服务器需要密码了。
  • DeathPenalty 的值设置为 None,会发现死亡不会掉落物品了。

执行重启容器的命令 docker compose restart 让修改生效。

记住,每一次修改后都需要重启容器生效。

恢复默认配置

删除 steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini 文件,重启容器即可。

升级版本

容器在启动时,会始终安装最新的 Palworld 服务端。有新版本发布后,重启容器便会发生重新安装并缓存最新版的现象。所以,重启即是升级。

当然,如果镜像本身发生了更新,你还是要执行 docker compose pull 拉取最新版镜像的。它可能跟游戏版本无关,但多了一些增强和修复。因为 steamapps 被缓存在宿主机目录了,所以更新甚至重建容器都不会出现重复安装或数据丢失。

结束语

此镜像是开源的,关联的仓库源码在 Hentioe/docker-steamcmd。祝大家游戏愉快。

作者头像 一点点入门知识 打赏作者
本文由作者按照 CC BY 4.0 进行授权
分享:

相关文章