A Linux DayZ server in a Docker container
Find a file
Daniel Ceregatti ec422a35d6 Update docs.
2024-06-21 22:57:31 -07:00
.gitignore First commit of the 'simple' branch. Maybe too simple? 2024-06-21 18:09:28 -07:00
docker-compose.yml Update docs. Add TL;DR. 2024-06-21 22:46:11 -07:00
Dockerfile Add CA certs, as steamcmd needs that too. YOU'D THINK PACKAGE DEPS WOULD COVER THIS... 2024-06-21 19:33:43 -07:00
LICENSE Initial commit 2022-03-25 23:24:01 +00:00
README.md Update docs. 2024-06-21 22:57:31 -07:00
start.sh Simplify Dockerfile even more. 2024-06-21 19:12:46 -07:00

DayZDockerServer

A Linux DayZ server in a Docker container.

The goal is to provide a vanilla DayZ server that can be spun up with as little as a machine running Linux with Docker and Docker Compose Plugin installed.

Features

This branch is called simple, because that's the intent: To keep things simple:

  • A Debian slim image with steamcmd and enough utilities installed to run a DayZ server.
  • All server and steamcmd files are persisted in the host user's home directory using a bind mount.
  • Everything else is left to the user to run by hand using commands similar to the official documentation.

TL;DR

git clone https://ceregatti.org/git/daniel/dayzdockerserver.git
cd dayzdockerserver
git checkout simple
echo "export USER_ID=$(id -u)" | tee .env
mkdir dayz
docker compose up -d --build
docker compose exec dayz bash
export STEAM_USERNAME='MySteamUserName'
steamcmd +login "${STEAM_USERNAME}" +quit
steamcmd +login "${STEAM_USERNAME}" +force_install_dir /home/user/serverfiles +app_update 223350 validate +quit
nano /home/user/serverfiles/serverDZ.cfg
cd /home/user/serverfiles
./DayZServer -config=serverDZ.cfg -port=2302 -BEpath=battleye -profiles=profiles -dologs -adminlog -netlog -freezecheck

Configure and Build

Ensure Docker and Docker compose plugin are installed.

Clone the repo, and change into the newly created directory, and check out the simple branch:

git clone https://ceregatti.org/git/daniel/dayzdockerserver.git
cd dayzdockerserver
git checkout simple

Create a .env file that contains your user id. The output of id -u has it:

echo "export USER_ID=$(id -u)" | tee .env

Create the directory where the server files will be stored:

mkdir dayz

Build the Docker image and bring the container up in the background:

docker compose up -d --build

This will bring up a single container where the server will run.

Usage

Everything is done in a shell inside the running container. All commands are run from this shell. Invoke the shell with:

docker compose exec dayz bash

A custom prompt will indicate when you are in the container. The prompt will look like this:

user@dayzdockerserver:~ $

Steam Integration

Use SteamCMD to login:

steamcmd +login 'MySteamLogin' +quit

Follow the prompts for the password and Steam Guard code. This process will wait indefinitely until both are entered. Once logged in, this process will not need to be repeated as long as the same username is used for the +login argument and the host directory containing the files is not deleted.

Install

The base server files must be installed before the server can be run:

steamcmd +login 'MySteamLogin' +force_install_dir /home/user/dayz/serverfiles +app_update 223350 validate +quit

This will download about 2.8G of files.

Replace 223350 with 1042420 for experimental.

Setup

Edit the server config file. One way is to do it within the container using the nano editor, the only one installed in the container:

nano /home/user/dayz/serverfiles/serverDZ.cfg

Another option is to edit it directly on the host, as at this point that file is also available there:

${EDITOR} ~/dayzdockerserver/serverfiles/serverDZ.cfg

Set the values of any variables there. See the documentation if you want, but most of the default values are fine. At the very least, change the server name:

hostname = "My Cool Server";   // Server name

Start

Start the server:

cd /home/user/dayz/serverfiles
./DayZServer -config=serverDZ.cfg

Stop

Hit control c to stop the server in the shell where it's running in the foreground.

Otherwise, open a new shell in the container and kill the process:

kill -TERM $(pidof DayZServer)

It takes time for the server to wrap things up, so always give it at least 30 seconds to fully shut down.

If the process does not exit, which it some times does, then you have to kill it:

kill -KILL $(pidof DayZServer)

Otherwise just bring the stack down. That will kill the server process as well:

docker compose down