Linux下用docker搭建Palworld服务器

1. 安装docker环境

以 debian 12 为例,安装docker,已有docker的可忽略

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

2. 搭Palworld服务器

基于steam的镜像 cm2network/steamcmd 去进一步安装Palworld

建议新建一个 screen 来运行以下内容,方便未来查看和管理

建一个文件夹用于管理 palworld 如建在 root 下,并在此目录中建一个 PalServer 用于之后保存游戏服务器的数据

mkdir /root/mypalworld_manage
mkdir /root/mypalworld_manage/PalServer

进 /root/mypalworld_manage 文件夹下

cd /root/mypalworld_manage

编辑一个启动脚本

vi start.sh

粘入以下内容

# 去掉之前的 palworld 容器(如果存在)
docker stop mypalworld
docker rm mypalworld

# 改PalServer文件夹权限
chmod -R 777 /root/mypalworld_manage/PalServer


# 创建 cm2network/steamcmd 镜像的容器,并后台运行
docker run -dit --name=mypalworld \
        -p 8211:8211/udp \
        -p 8211:8211/tcp \
        -v /root/mypalworld_manage/PalServer:/home/steam/Steam/steamapps/common/PalServer \
        cm2network/steamcmd


# 让容器内也有权限修改 PalServer 文件夹
docker exec -u root mypalworld /bin/bash -c "chmod -R 777 /home/steam"


# 匿名登录 steam 并安装 Palworld 服务端
docker exec mypalworld /bin/bash -c "/home/steam/steamcmd/steamcmd.sh +login anonymous +app_update 2394010 validate +quit"

# 运行 Palworld 服务端
docker exec mypalworld /bin/bash -c "/home/steam/Steam/steamapps/common/PalServer/PalServer.sh --players 10 --useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS"

粘入以后,按Esc,输入 :wq 进行保存

运行刚写好的脚本

sh start.sh

这一步可能会花费不少时间,可能至少几分钟以上,主要是要安装服务端

安装过程中有可能控制台长时间看不到中间反馈(个人尝试有这问题,主要是 docker 外部运行指令导致的),但不用管,等等就好

直到命令行显示类似如下内容后则代表服务器已启动

 Update state (0x101) committing, progress: 64.22 (3037163149 / 4729437191)
 Update state (0x101) committing, progress: 64.22 (3037163149 / 4729437191)
 Update state (0x101) committing, progress: 64.22 (3037163149 / 4729437191)
Success! App '2394010' fully installed.
sh: 1: xdg-user-dir: not found
[S_API] SteamAPI_Init(): Loaded local 'steamclient.so' OK.
Shutdown handler: initalize.
- Existing per-process limit (soft=1048576, hard=1048576) is enough for us (need only 1048576)
Increasing per-process limit of core file size to infinity.
- Existing per-process limit (soft=18446744073709551615, hard=18446744073709551615) is enough for us (need only 18446744073709551615)
CAppInfoCacheReadFromDiskThread took 36 milliseconds to initialize
Setting breakpad minidump AppID = 2394010
[S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.

3. 连接服务器

注意要开启服务器的 8211 端口

游戏中选择“加入多人游戏(专用服务器)”

在最下方的输入框输入:

你的服务器IP:8211

点击“联系”(翻译有问题,应该是连接)

即可加入自己的服务器

发表评论