1. Firstly, you need to register a SRCDS_TOKEN token from this website ( source)
  2. Run the following command to start a csgo dedicated server
docker run -d --net=host -e SRCDS_PORT=27016 -e SRCDS_TV_PORT=27021 -e SRCDS_RCONPW=rcon-password -e SRCDS_PW=server-password -e SRCDS_MAXPLAYERS=64 -e SRCDS_STARTMAP=cs_italy -e SRCDS_TOKEN={my-token} --name=csgo-dedicated  cm2network/csgo

Where -e <var name>=<value> arguments are options for the server. You can also set some other following arguments

  • "SRCDS_RCONPW=my rcon password"  (value can be overwritten by csgo/cfg/server.cfg)
    "SRCDS_PW=my password",
    "SRCDS_MAXPLAYERS=64",
    "SRCDS_STARTMAP=cs_italy",
    "SRCDS_TOKEN={registered token}",
    "SRCDS_PORT=27016", (port used for client to connect to the server)
    "SRCDS_TV_PORT=27021",
    "STEAMAPPID=740",
    "SRCDS_FPSMAX=300",
    "SRCDS_TICKRATE=128",
    "SRCDS_CLIENT_PORT=27005",
    "SRCDS_REGION=3",
    "SRCDS_MAPGROUP=mg_active",
    "SRCDS_GAMETYPE=0",
    "SRCDS_GAMEMODE=1"

-name=csgo-dedicated is used to name the container for latter server management.

All default environment value (setup via -e or default values) can be checked with docker inspect csgo-dedicated)

Refer to this website to check game mode list. The default game mode is competitive (configuration file: gamemode_competitive.cfg. This file name will be used in the next section).

3. (Optional) After the container is created, it will detect the game data existence and automatically download the game data and start the server. However, you will start recognize that the game will be full of bots at any start of a game.

To disable this bot automatic bot addition and customize other features. Do following steps

run docker exec -it -u 0 csgo-dedicated bash. New command prompt will appear, then run following command in the newly created command prompt.

apt update && apt install -yq vim
cd /home/steam/csgo-dedicated/csgo/cfg
vim gamemode_competitive.cfg

Then change bot_quota 0, mp_freezetime 3, etc.. and any other configuration.

You also can use script to apply the configuration on all game mode. For e.g.

for f in gamemode_*.cfg; do echo "update $f"; sed -i "s/bot_quota\t.*[0-9]*/bot_quota\t\t0/"  $f; done

Beside gamemode configuration, you also can update server configuration (a kind of higher level compared to game mode confg), by editing file at path /home/steam/csgo-dedicated/csgo/cfg/server.cfg. These configuration will overwrite config setup previously in the docker command via -e arguments.
Some configurations such as rcon_password "my server password" can be configured here.

After modify needed files, quit the sub-shell (command prompt). The restart the container with docker restart csgo-dedicated.

4. To send server command via RCON.

Note: currently, these commands does not work, and the console will complain with Lost RCON connection, please retry command.

In the game console, execute

rcon_address <server address>
rcon_password <server aport>
rcon <server command>

<server command> can be e.g. changelevel cs_italy to force changing map (without voting).

5. (optional) server error

Server log can be observed with docker logs -f --tail 1000 csgo-dedicated.

There are several errors can be solved manually. Such as

Setting breakpad minidump AppID = 730dlopen failed trying to load:/home/steam/.steam/sdk32/steamclient.sowith error:/home/steam/.steam/sdk32/steamclient.so: cannot open shared object file: No such file or directory

This error can be fixed by running the following command in the container shell (via docker exec -it csgo-dedicated bash )

mkdir /home/steam/.steam/sdk32
ln -s /home/steam/steamcmd/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so

Note that fixing this error is optional. The server works perfectly even though this error is displayed.

6. (optional) Store game data to a customized location

The game data consumes up to 23Gb. This section helps you customize the location of the game data.

However, this belongs to a general usage of docker. I will go on another post and update the link here.