搜索镜像
docker search steamcmd
拉取镜像
本次使用cm2network/steamcmd镜像去部署游戏服务器;使用steamcmd/steamcmd镜像亦可,二者操作方面并无太大区别;
docker pull cm2network/steamcmd:latest
注:镜像Tag可通过Docker Hub查看。
相关配置
- Web仪表盘端口(非必要端口)
-p 8080:8080
- Telnet端口(非必要端口)
-p 8081:8081
- Alloc模块端口(非必要端口),默认Web仪表盘端口+2
-p 8082:8082
- 服务器tcp端口(必要端口),局域网端口请保持在26900 ~ 26905或27015 ~ 27020 的范围内
-p 26900:26900
- 服务器udp端口(必要端口),默认为服务器tcp端口及向后偏移3位,仅在服务器在线玩家交互过多时启用
-p 26901:26901/udp -p 26901:26901/udp -p 26902:26902/udp -p 26903:26903/udp
- 挂载steamcmd数据以及7 Days To Die服务器数据
-v /docker/7dtd:/home/server
运行容器
启动容器,并进入容器交互终端;物理机或云服务器需放行端口;
docker run -it --name 7dtd -p 8080:8080 -p 8081:8081 -p 8082:8082 -p 26900:26900 -p 26900:26900/udp -p 26901:26901/udp -p 26902:26902/udp -p 26903:26903/udp -v /docker/7dtd:/home/server cm2network/steamcmd bash
下载服务器
执行steamcmd
命令匿名登录并安装7 Days To Die
服务器,如有问题参考SteamCMD文档;
./steamcmd.sh +force_install_dir /home/server +login anonymous +app_update 294420 -beta latest_experimental validate +quit
运行服务器
./startserver.sh -configfile=serverconfig.xml
GPU支持
服务器在启动过程中,会调用GPU去进行着色器渲染,而docker容器是无法直接访问GPU的,因此会产生以下类似的报错;
ERROR: Shader Sprites/Default shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Sprites/Mask shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Legacy Shaders/VertexLit shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
WARNING: Shader Unsupported: 'Legacy Shaders/Diffuse' - All subshaders removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?
ERROR: Shader Legacy Shaders/Diffuse shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
WARNING: Shader Unsupported: 'Legacy Shaders/Diffuse' - All subshaders removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?
WARNING: Shader Unsupported: '7DTD/Cube_UI_Frame' - All subshaders removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?
ERROR: Shader 7DTD/Cube_UI_Frame shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
WARNING: Shader Unsupported: '7DTD/Cube_UI_Frame' - All subshaders removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?
ERROR: Shader GUI/Text Shader shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
WARNING: Shader Unsupported: '7DTD/Cube_UI_Glow' - All subshaders removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?
ERROR: Shader 7DTD/Cube_UI_Glow shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
WARNING: Shader Unsupported: '7DTD/Cube_UI_Glow' - All subshaders removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader If subshaders removal was intentional, you may have forgotten turning Fallback off?
ERROR: Shader Unlit/Transparent Colored shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
如物理机或云服务器无GPU,忽略此问题即可。若需要为7 Days To Die
服务器提供GPU支持,请先安装CUDA。并在运行容器步骤时,开启GPU准虚拟化支持;
docker run -it --name 7dtd --gpus=all --net=host -v /docker/7dtd:/home/server cm2network/steamcmd bash
SteanNetworking
无论是使用云服务器还是物理机部署7 Days To Die
服务的前提是需要有公网IP,但国内IPV4
资源紧张,如果是使用家用网络的情况下,客户端访问不到NAT路由器后的服务器;若想解决这种问题,就需要使用NAT穿透技术,普遍的解决方案是内网穿透(FRP)、虚拟专用网络(VPN)、对等网络(P2P)等。
7 Days To Die
服务器提供了两种网络模式:LiteNetLib
和SteamNetworking
。LiteNetLib
模式适用于公网IP直连,服务器与客户端不存在NAT路由器的情况;而SteamNetworking
模式则适用于服务器和客户端存在NAT路由器的情况,该模式实现了P2P
通讯。
修改serverconfig.xml
配置文件中的ServerDisabledNetworkProtocols
的值为LiteNetLib
;
<property name="ServerDisabledNetworkProtocols" value="LiteNetLib"/>
运行服务器,服务器启动之后,便可在客户端服务器面板看到对应信息,此时面板展示的服务器IP为动态公网IP。如果不想暴露自身IP,可使用内网穿透工具,作一层套壳,当第一次使用内网穿透服务的IP访问7 Days To Die
服务器后,客户端服务器面板展示的IP即为内网穿透服务的IP。