Go to file
Astra e9c284be62 Change README.md 2025-04-03 07:05:10 +01:00
.github/workflows Migrate from bullseye to bookworm 2024-10-11 17:12:32 +01:00
bookworm Update entry.sh 2025-04-01 19:17:59 +01:00
examples Add DEBUG variable to control logging verbosity 2025-02-09 19:36:21 +00:00
.gitignore Update files 2025-03-19 14:55:55 +00:00
LICENSE Initial commit 2023-09-30 16:52:25 +01:00
README.md Change README.md 2025-04-03 07:05:10 +01:00

README.md

What is Counter-Strike 2?

For over two decades, Counter-Strike has offered an elite competitive experience, one shaped by millions of players from across the globe. And now the next chapter in the CS story is about to begin. This is Counter-Strike 2. This Docker image contains the dedicated server of the game.

logo

How to use this image

Hosting a simple game server

Running on the host interface (recommended):

$ docker run -d --net=host --name=cs2 --env-file=.cs2.env git.zio.sh/astra/cs2:latest

.cs2.env:

CS2_IP=
CS2_PORT=27015
CS2_SERVERNAME=cs2.host.eu
CS2_RCONPW=changeme
CS2_PW=changeme
CS2_BOT_DIFFICULTY=1
CS2_BOT_QUOTA=0
CS2_SERVER_HIBERNAME=0
CS2_MAXPLAYERS=36
CS2_CHEATS=0
CS2_GAMEALIAS=custom
SRCDS_TOKEN=changeme
STEAMAPPVALIDATE=0
TV_ENABLE=0

Running using a bind mount for data persistence on container recreation:

$ mkdir -p $(pwd)/cs2-data
$ chmod 777 $(pwd)/cs2-data # Makes sure the directory is writeable by the unprivileged container user
$ docker run -d \
  --net=host \
  -v $(pwd)/cs2-data:/home/steam/cs2-dedicated/ \
  --name=cs2-dedicated \
  --env-file=.cs2.properties \
  git.zio.sh/astra/cs2:latest

The container will automatically update the game on startup, so if there is a game update just restart the container.

Configuration

System Requirements

Please note that you need approximately 1.5g of free RAM. If this is not available, container will crash with err 137.

Environment Variables

Feel free to overwrite these environment variables, using -e (--env) or --env-file (recommended):

Server Configuration

SRCDS_TOKEN=""              (Game Server Token from https://steamcommunity.com/dev/managegameservers)
CS2_SERVERNAME="changeme"   (Set the visible name for your private server)
CS2_CHEATS=0                (0 - disable cheats, 1 - enable cheats)
CS2_SERVER_HIBERNATE=0      (Put server in a low CPU state when there are no players. 
                             0 - hibernation disabled, 1 - hibernation enabled
                             n.b. hibernation has been observed to trigger server crashes)
CS2_IP=""                   (CS2 server listening IP address, 0.0.0.0 - all IP addresses on the local machine, empty - IP identified automatically)
CS2_PORT=27015              (CS2 server listen port tcp_udp)
CS2_RCON_PORT=""            (Optional, use a simple TCP proxy to have RCON listen on an alternative port.
                             Useful for services like AWS Fargate which do not support mixed protocol ports.)
CS2_LAN="0"                 (0 - LAN mode disabled, 1 - LAN Mode enabled)
CS2_RCONPW="changeme"       (RCON password)
CS2_PW="changeme"           (Optional, CS2 server password)
CS2_MAXPLAYERS=10           (Max players)
CS2_ADDITIONAL_ARGS=""      (Optional additional arguments to pass into cs2)

Note: When using CS2_RCON_PORT don't forget to map the port chosen with TCP protocol (e.g., add -p 27050:27050/tcp on the docker run command or add the port to the docker-compose.yml file).

Game Modes

CS2_GAMEALIAS=""            (Game type, e.g. casual, competitive, deathmatch.
                             See https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
CS2_GAMETYPE=0              (Used if CS2_GAMEALIAS not defined. See https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
CS2_GAMEMODE=1              (Used if CS2_GAMEALIAS not defined. See https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
CS2_MAPGROUP="mg_active"    (Map pool. Ignored if workshop maps are defined.)
CS2_STARTMAP="de_inferno"   (Start map. Ignored if workshop maps are defined.)

Bots

CS2_BOT_DIFFICULTY=""       (0 - easy, 1 - normal, 2 - hard, 3 - expert)
CS2_BOT_QUOTA=""            (Number of bots)
CS2_BOT_QUOTA_MODE=""       (fill, competitive)

CSTV/SourceTV

TV_ENABLE=0                 (0 - disable, 1 - enable)
TV_PORT=27020               (SourceTV/CSTV port to bind to)
TV_AUTORECORD=0             (Automatically record all games as CSTV demos: 0=off, 1=on)
TV_PW="changeme"            (CSTV password for clients)
TV_RELAY_PW="changeme"      (CSTV password for relay proxies)
TV_MAXRATE=0                (Max CSTV spectator bandwidth rate allowed, 0 == unlimited)
TV_DELAY=0                  (CSTV broadcast delay in seconds)

Logs

CS2_LOG="on"                ('on'/'off')
CS2_LOG_MONEY=0             (Turns money logging on/off: 0=off, 1=on)
CS2_LOG_DETAIL=0            (Combat damage logging: 0=disabled, 1=enemy, 2=friendly, 3=all)
CS2_LOG_ITEMS=0             (Turns item logging on/off: 0=off, 1=on)

Steam Workshop

Support for Steam Workshop is experimental!

CS2_HOST_WORKSHOP_MAP=""         (Steam Workshop Map ID to load on server start)   
CS2_HOST_WORKSHOP_COLLECTION=""  (Steam Workshop Collection ID to download)

If a Workshop Collection is set, maps can be selected via rcon. E.g:

ds_workshop_listmaps
ds_workshop_changelevel $map_name

Customizing this Container

Debug Logging

If you want to increase the verbosity of log output set the DEBUG environment variable:

DEBUG=0                    (0=none, 1=steamcmd, 2=cs2, 3=all)

Validating Game Files

If you break the game through your customisations and want steamcmd to validate and redownload then set the STEAMAPPVALIDATE environment variable to 1:

STEAMAPPVALIDATE=0          (0=skip validation, 1=validate game files)

Pre and Post Hooks

The container includes two scripts for executing custom actions:

  • /home/steam/cs2-dedicated/pre.sh is executed before the CS2 server starts
  • /home/steam/cs2-dedicated/post.sh is executed after the CS2 server stops

When using a persient volume mounted at /home/steam/cs2-dedicated/ you may edit these scripts to perform custom actions, such as enabling metamod.

Alternatively, you may have docker mount files from outside the container to override these files. E.g.:

-v /path/to/pre.sh:/home/steam/cs2-dedicated/pre.sh

Overriding Game Mode Defaults

The default configurations for each game mode are stored in /home/steam/cs2-dedicated/game/csgo/cfg/. For example, the Competitive mode defaults are set by gamemode_competitive.cfg.

When using a persistent volume mounted at /home/steam/cs2-dedicated/, these defaults can be overridden by adding your own settings to gamemode_competitive_server.cfg.

// Game Mode Competitive Server Overrides 

mp_maxrounds	16	// Shorter games

Customisation Bundle

The container can be instructed to download a extract a Tar Gzip bundle, Tar or Zip archive of configuration files and other customisations from a given URL.

CS2_CFG_URL=""          (HTTP/HTTPS URL to fetch a Tar Gzip bundle, Tar or Zip archive of configuration files/mods)

Credits

This container leans heavily on the work of CM2Walki, especially his SteamCMD container image. GG!