Docker 安装
如何使用 Docker 搭建 nanos world 服务器。
Docker 设置由社区维护。欲了解更多详情,请访问开源 GitHub 仓库:nanos-world-server Docker。
你可以使用 Docker 在容器化环境中运行 nanos world 服务器。此方法适用于任何支持 Docker 的系统(Linux、Windows、macOS)。
前提条件
- Docker(20.10 或更高版本)
- Docker Compose(2.0 或更高版本)
- 至少 100MB 的可用磁盘空间
使用 Docker Compose 快速开始
1. 创建一个 docker-compose.yml 文件:
services:
nanos-world-server:
image: olivatooo/nanos-world-server:latest
restart: unless-stopped
# Uncomment to always have the latest version
# pull_policy: always
ports:
- "7777:7777/udp"
- "7777:7777/tcp"
- "7778:7778/udp"
volumes:
- ./Packages:/app/Packages
- ./Assets:/app/Assets
- ./logs:/app/.logs
# Uncomment and modify to pass parameters to the server
# command: ["--port", "7777", "--map", "default-testing-map"]
Port 7777 is the game port (UDP) and the built-in HTTP server (TCP), and 7778 (UDP) is the query port used by the Server List.
2. 启动服务器:
docker compose up -d
3. 查看日志:
docker compose logs -f
4. 停止服务器:
docker compose down
If you are using an older Docker installation, use docker-compose (with a hyphen) instead of docker compose.
使用 Docker CLI
或者,你也可以直接使用 Docker 运行服务器:
docker run -p 7777:7777/udp -p 7777:7777/tcp -p 7778:7778/udp olivatooo/nanos-world-server
配置
你可以通过修改 docker-compose.yml 中的 command 部分来传递服务器参数:
command: ["--max_players", "32", "--announce", "1", "--game_mode", "sandbox"]
All available parameters are listed in Server Configuration.
By default the server runs as the Playtest Steam App. To change it, pass "--steam_app", "game" in the command.
持久化数据
The Docker configuration above mounts these folders from your host into the container (/app):
./Packagesand./Assets: add your custom Packages and Asset Packs, they are kept between container restarts./logs: the server logs
The Config.toml lives inside the container and is recreated with the image, so pass your settings through the command parameters instead.
更新服务器
要更新到最新版本:
docker-compose pull
docker-compose up -d