Skip to content

🐋 📦 Creates a Half-Life Dedicated Server instance using Docker including the ability to add custom configurations, mods and plugins.

License

Notifications You must be signed in to change notification settings

JamesIves/hlds-docker

Repository files navigation

Half-Life Dedicated Server With Docker 🐋 📦

Crowbar

Creates a Half-Life Dedicated Server instance using Docker. You can run any games the Half-Life Dedicated Server client supports out of the box, including the ability to add custom configurations, mods and plugins.

Setup ⚙️

Before starting, ensure you have the Docker daemon and the Docker CLI tool installed and available.

Important

The following steps will not work if you use an ARM architecture system. For best results, use a system running x86-64.

Pre-Built Images

If you're just looking to start a server as quickly as possible you can follow these steps to use a pre-built image on Docker Hub or the GitHub Container Registry.

  1. Create a docker-compose.yml file by copying and pasting the example below. Adjust the image property so the tag name corresponds with the game you want to use. Additionally you can adjust the server startup arguments by modifying the command property; for a list of available arguments, visit the Valve Developer Wiki.

Note

In the majority of cases you'll need to specify +map for the server to be joinable.

services:
  hlds:
    build: docker
    # 📣 Adjust the image value here with the desired game you want the server to use.
    image: jives/hlds:cstrike
    volumes:
      - "./config:/temp/config"
      - "./mods:/temp/mods"
    ports:
      - "27015:27015/udp"
      - "27015:27015"
      - "26900:2690/udp"
    environment:
      - GAME=${GAME}
    # 📣 Modify your server startup commands here.
    # 📣 Remember: Stating map is based on the game, and will likely be different between images.
    command: +maxplayers 12 +map cs_italy

Tip

Available images include:

  1. Start the image. Once the Half-Life Dedicated Server client starts, you'll receive a stream of messages, including the server's public IP address and any startup errors.
docker compose up
  1. Connect to your server via the IP address by loading the game on Steam and start playing. You must own a copy of the game on Steam in order to play. ⌨️

Building an Image

If you want to build an image yourself, you can follow the steps below. This can be useful in cases where you want to make changes to the build scripts.

  1. Clone this project.
  2. Define the game you want the server to run. You can do this by setting an environment variable on your command line.
export GAME=cstrike

Before continuing to the next steps, verify that the environment variable is set by running echo $GAME in your terminal. It should send back the variable you just set.

Tip

Available options include:

  1. Build the image.
docker compose build
  1. If you want to modify the server startup arguments, you can provide a command property within docker-compose.yml; for a list of available arguments, visit the Valve Developer Wiki.

Note

In the majority of cases you'll need to specify +map for the server to be joinable.

services:
  hlds:
    command: +maxplayers 16 +map cs_italy
  1. Start the image. Once the Half-Life Dedicated Server client starts, you'll receive a stream of messages, including the server's public IP address and any startup errors.
docker compose up
  1. Connect to your server via the IP address by loading the game on Steam and start playing. You must own a copy of the game on Steam in order to play. ⌨️

Server Configuration 🔧

Configs and Plugins

If you wish to add server configurations, such as add-ons, plugins, map rotations, etc, you can add them to the config directory. Any configuration files will be copied into the container on start and placed within the folder for the specified game. For example, if you set the game as cstrike, the contents of the config folder will be placed within the cstrike directory on the server.

Custom Mods

If you want to run a custom mod, you can do so with the mods directory. Similar to the config directory, this folder will be copied into your container on start alongside the other game folders.

  1. Add your mod files as a sub-directory of mods. For example if the mod name is decay, you'd place it in mods/decay.
  2. Define the GAME environment variable so it points to your mod name. This works if you're using a pre-built image docker-compose.yml or by building one yourself.
export GAME=decay
  1. Build the image. If you don't want to build the image, I suggest using the pre-built jives/hlds:valve image.
docker compose build
  1. Start the image. Most Half-Life mods require specific startup arguments, refer to the Valve Developer Wiki and the instructions for the mod you're trying to run for more details. You can find details about how to add these above.
docker compose up

Ownership 🧰

The Half-Life Dedicated Server client, Steam, SteamCMD and the titles themselves are property and ownership of Valve Software. All this software does is make it easier to interface with their provided tooling.