# DayZDockerServer A Linux [DayZ](https://dayz.com) server in a [Docker](https://docs.docker.com/) 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 ```shell 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 ``` ```docker export STEAM_USERNAME='MySteamUserName' steamcmd +login "${STEAM_USERNAME}" +quit steamcmd +login "${STEAM_USERNAME}" +force_install_dir /home/user/dayz/serverfiles +app_update 223350 validate +quit nano /home/user/dayz/serverfiles/serverDZ.cfg cd /home/user/dayz/serverfiles ./DayZServer -config=serverDZ.cfg ``` ## Configure and Build Ensure [Docker](https://docs.docker.com/engine/install/) and [Docker compose plugin](https://docs.docker.com/compose/install/) are installed. Clone the repo, and change into the newly created directory, and check out the `simple` branch: ```shell 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: ```shell echo "export USER_ID=$(id -u)" | tee .env ``` Create the directory where the server files will be stored: ```shell mkdir dayz ``` Build the Docker image and bring the container up in the background: ```shell 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: ```shell 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](https://developer.valvesoftware.com/wiki/SteamCMD) to login: ```docker 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: ```docker 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: ```docker 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: ```shell ${EDITOR} ~/dayzdockerserver/serverfiles/serverDZ.cfg ``` Set the values of any variables there. See the [documentation](https://forums.dayz.com/topic/239635-dayz-server-files-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: ```docker 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: ```docker 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: ```docker kill -KILL $(pidof DayZServer) ``` Otherwise just bring the stack down. That will kill the server process as well: ```shell docker compose down ```