joedwards32 / CS2

CS2 Dedicated Server Docker Image
https://hub.docker.com/r/joedwards32/cs2
MIT License
300 stars 56 forks source link

What's the process for kicking off multiple cs2-dedi containers? #108

Closed zahti closed 5 months ago

zahti commented 7 months ago

Is it possible to kickoff another container 'under' cs2-docker using the same image and persistent data volume I already have setup? I would like one container running wingman and one container running competitive.

image

Can I just have a duplicate .yml file in the cs2-docker directory? And change the following lines of code?

container_name: cs2-dedicated-wingman --> cs2-dedicated-competitive environment:

ports:

If it matters, I am using a persistent data volume as well: volumes:

For example, current setup that I was hoping would work: image

zahti commented 7 months ago

Or do I need to duplicate my "cs2-docker" folder with a different name? (Keeping the docker-compose.yml file the same name.) ~/cs2-docker-wingman/docker-compose.yml ~/cs2-docker-competitive/docker-compose.yml

I have tried this method with no luck. Cannot even get the 2nd server available for LAN connections. Maybe it has to do with pointing to the same persistent data mount? image

The only server I ever see in the server browser is the 'wingman' 27015 server. The 27016 one refuses connections / isn't setup correctly. What's weird is that there aren't any strange messages in the server log/shell.

zahti commented 7 months ago

Any ideas? I have a LAN party on the 20th that I am trying to prep for :100:

joedwards32 commented 7 months ago

Hi @zahti,

You can take either approach. The most important things to get right are:

version: '3.7'
services:
  cs2-server-1:
    image: joedwards32/cs2
    container_name: cs2-server-1
    environment:
      # Server configuration
      - SRCDS_TOKEN                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=changeme     # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=0      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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             # (CS2 server password)
      - CS2_MAXPLAYERS=10           # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # 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)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=changeme              # CSTV password for clients
      - TV_RELAY_PW=changeme        # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - cs2-1:/home/steam/cs2-dedicated/  # Persistent data volume mount point inside container
    ports:
      - "27015:27015/tcp"           # TCP
      - "27015:27015/udp"           # UDP
      - "27020:27020/udp"           # UDP
  cs2-server-2:
    image: joedwards32/cs2
    container_name: cs2-server-2
    environment:
      # Server configuration
      - SRCDS_TOKEN                 # Game Server Token from https://steamcommunity.com/dev/managegameservers. NOTE: Servers must have unique tokens.
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=changeme     # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=0      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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             # (CS2 server password)
      - CS2_MAXPLAYERS=10           # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # 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)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=changeme              # CSTV password for clients
      - TV_RELAY_PW=changeme        # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - cs2-2:/home/steam/cs2-dedicated/  # Persistent data volume mount point inside container
    ports:
      - "27115:27015/tcp"           # TCP - NOTE: Host side of the port mapping has changed to avoid port collisions
      - "27115:27015/udp"           # UDP - NOTE: Host side of the port mapping has changed to avoid port collisions
      - "27120:27020/udp"           # UDP - NOTE: Host side of the port mapping has changed to avoid port collisions
volumes:
  cs2-1:
  cs2-2:
zahti commented 7 months ago

Thank you for the details and explanation. I believe my issue was due to these 2 points, I was violating both of these!

I have one additional question regarding the syntax of your persistent volume:

volumes:
      - cs2-1:/home/steam/cs2-dedicated/  # Persistent data volume mount point inside container

Why do you put the cs2-1 string? Are you just giving an example of where to replace with a directory? Or does the cs2-1 actually stay in the code when running docker compose?

Here is how my .yml file looks for one of the persistent mount locations:

volumes:
      - /home/zahti/cs2data:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container

And then the folder is here - this seems to be working well (for running a single server at once): image

I am asking this question because I am trying to figure out if I should just make another folder (e.g., /home/zahti/cs2data-2) for cs2-server-2?

I also see at the end of the .yml you have these lines, what should I do here?

volumes:
  cs2-1:
  cs2-2:

If it's useful, here is my docker-compose.yml file for 2 servers at once, following your advice. However, I would like to understand the purpose of the syntax of your persistent volume mount vs. how I implemented it. As you can see, I didn't change the last 2 lines... is that okay?

version: '3.7'
services:
  cs2-server-1:
    image: joedwards32/cs2
    container_name: cs2-server-1
    environment:
      # Server configuration
      - SRCDS_TOKEN=changeme                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=changeme    # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=1      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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=                     # (CS2 server password)
      - CS2_MAXPLAYERS=4            # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # Game modes https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
      - CS2_GAMEALIAS=wingman       # (Game type, e.g. casual, competitive, deathmatch, wingman)
      - CS2_GAMETYPE=0              # (Used if CS2_GAMEALIAS not defined)
      - CS2_GAMEMODE=1              # (Used if CS2_GAMEALIAS not defined)
      - CS2_MAPGROUP=mg_active      # (Map pool)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=tvpass                # CSTV password for clients
      - TV_RELAY_PW=relaypass       # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - /home/zahti/cs2data-1:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container
    ports:
      - "27015:27015/tcp"           # TCP
      - "27015:27015/udp"           # UDP
      - "27020:27020/udp"           # UDP
    stdin_open: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
    tty: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
  cs2-server-2:
    image: joedwards32/cs2
    container_name: cs2-server-2
    environment:
      # Server configuration
      - SRCDS_TOKEN=changeme                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=changeme    # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=1      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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=                     # (CS2 server password)
      - CS2_MAXPLAYERS=10            # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # Game modes https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
      - CS2_GAMEALIAS=competitive       # (Game type, e.g. casual, competitive, deathmatch, wingman)
      - CS2_GAMETYPE=0              # (Used if CS2_GAMEALIAS not defined)
      - CS2_GAMEMODE=1              # (Used if CS2_GAMEALIAS not defined)
      - CS2_MAPGROUP=mg_active      # (Map pool)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=tvpass                # CSTV password for clients
      - TV_RELAY_PW=relaypass       # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - /home/zahti/cs2data-2:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container
    ports:
      - "27115:27015/tcp"           # TCP
      - "27115:27015/udp"           # UDP
      - "27120:27020/udp"           # UDP
    stdin_open: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
    tty: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
volumes:
  cs2-1:
  cs2-2:
zahti commented 7 months ago

Another question, do I need to change CS2_PORT and TV_PORT in the cs2-server-2 service? I am only seeing the first server available on LAN after it says both of them are running: image

image

joedwards32 commented 7 months ago

Hi,

Here's the documentation for Volumes in Docker Compose: https://docs.docker.com/compose/compose-file/07-volumes/

The way I am declaring volumes (cs2-1, cs2-2) is basically telling Docker that I want two volumes with the specified names/labels, and docker will decide where to create them based on the system config.

For example, on Ubuntu:

/var/lib/docker/volumes/cs2-1/_data

So I declare that I want two volumes and then I map each volume into the containers.

If you are declaring the volume paths explicitly then you can omit the volumes block at the bottom.

version: '3.7'
services:
  cs2-server-1:
    image: joedwards32/cs2
    container_name: cs2-server-1
    environment:
      # Server configuration
      - SRCDS_TOKEN=changeme                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=changeme    # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=1      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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=                     # (CS2 server password)
      - CS2_MAXPLAYERS=4            # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # Game modes https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
      - CS2_GAMEALIAS=wingman       # (Game type, e.g. casual, competitive, deathmatch, wingman)
      - CS2_GAMETYPE=0              # (Used if CS2_GAMEALIAS not defined)
      - CS2_GAMEMODE=1              # (Used if CS2_GAMEALIAS not defined)
      - CS2_MAPGROUP=mg_active      # (Map pool)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=tvpass                # CSTV password for clients
      - TV_RELAY_PW=relaypass       # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - /home/zahti/cs2data-1:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container
    ports:
      - "27015:27015/tcp"           # TCP
      - "27015:27015/udp"           # UDP
      - "27020:27020/udp"           # UDP
    stdin_open: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
    tty: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
  cs2-server-2:
    image: joedwards32/cs2
    container_name: cs2-server-2
    environment:
      # Server configuration
      - SRCDS_TOKEN=changeme                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=changeme    # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=1      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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=                     # (CS2 server password)
      - CS2_MAXPLAYERS=10            # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # Game modes https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
      - CS2_GAMEALIAS=competitive       # (Game type, e.g. casual, competitive, deathmatch, wingman)
      - CS2_GAMETYPE=0              # (Used if CS2_GAMEALIAS not defined)
      - CS2_GAMEMODE=1              # (Used if CS2_GAMEALIAS not defined)
      - CS2_MAPGROUP=mg_active      # (Map pool)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=tvpass                # CSTV password for clients
      - TV_RELAY_PW=relaypass       # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - /home/zahti/cs2data-2:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container
    ports:
      - "27115:27015/tcp"           # TCP
      - "27115:27015/udp"           # UDP
      - "27120:27020/udp"           # UDP
    stdin_open: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
    tty: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
zahti commented 7 months ago

Thank you, that makes sense!

joedwards32 commented 7 months ago

You don't need to change CS2_PORT or TV_PORT as these control the ports the cs2 server binds to inside the container.

As mentioned before, the same ports can be used inside the container without collisions, you just need to make sure that host ports are not colliding.

joedwards32 commented 7 months ago

If this is for a LAN party, I also recommend you set CS2_SERVER_HIBERNATE=0 to disable hibernation.

There is a cs2 server bug (nothing to do with the container) where the server sometimes crashes when waking from hibernation.

zahti commented 7 months ago

You don't need to change CS2_PORT or TV_PORT as these control the ports the cs2 server binds to inside the container.

As mentioned before, the same ports can be used inside the container without collisions, you just need to make sure that host ports are not colliding.

Thanks. I believe I am doing everything correctly but I am not able to get this to work. I just tried switching over to native docker (not desktop client) to see if that was impacting - same results though.

image

It is still only ever showing the 27015 (cs2-server-1) available for connection on LAN image

docker-compose.yml is exactly as below, except for the token1 and token2 are redacted.

version: '3.7'
services:
  cs2-server-1:
    image: joedwards32/cs2
    container_name: cs2-server-1
    environment:
      # Server configuration
      - SRCDS_TOKEN=token1                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=Wingman | STORM Esports    # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=0      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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=password       # (RCON password)
      - CS2_PW=                     # (CS2 server password)
      - CS2_MAXPLAYERS=4            # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # Game modes https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
      - CS2_GAMEALIAS=wingman       # (Game type, e.g. casual, competitive, deathmatch, wingman)
      - CS2_GAMETYPE=0              # (Used if CS2_GAMEALIAS not defined)
      - CS2_GAMEMODE=1              # (Used if CS2_GAMEALIAS not defined)
      - CS2_MAPGROUP=mg_active      # (Map pool)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=tvpass                # CSTV password for clients
      - TV_RELAY_PW=relaypass       # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - /home/zahti/cs2data-1:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container
    ports:
      - "27015:27015/tcp"           # TCP
      - "27015:27015/udp"           # UDP
      - "27020:27020/udp"           # UDP
    stdin_open: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
    tty: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
  cs2-server-2:
    image: joedwards32/cs2
    container_name: cs2-server-2
    environment:
      # Server configuration
      - SRCDS_TOKEN=token2                 # Game Server Token from https://steamcommunity.com/dev/managegameservers
      - STEAMAPPVALIDATE=0          # (0 - no validation, 1 - enable validation)
      - CS2_SERVERNAME=Competitive | STORM Esports    # (Set the visible name for your private server)
      - CS2_CHEATS=0                # (0 - disable cheats, 1 - enable cheats)
      - CS2_PORT=27015              # (CS2 server listen port tcp_udp)
      - CS2_SERVER_HIBERNATE=0      # (Put server in a low CPU state when there are no players. 0 - hibernation disabled, 1 - hibernation enabled)
      - 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=password       # (RCON password)
      - CS2_PW=                     # (CS2 server password)
      - CS2_MAXPLAYERS=10            # (Max players)
      - CS2_ADDITIONAL_ARGS         # (Optional additional arguments to pass into cs2)
      - CS2_CFG_URL                 # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
      # Game modes https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
      - CS2_GAMEALIAS=competitive       # (Game type, e.g. casual, competitive, deathmatch, wingman)
      - CS2_GAMETYPE=0              # (Used if CS2_GAMEALIAS not defined)
      - CS2_GAMEMODE=1              # (Used if CS2_GAMEALIAS not defined)
      - CS2_MAPGROUP=mg_active      # (Map pool)
      - CS2_STARTMAP=de_inferno     # (Start map)
      # Bots
      - CS2_BOT_DIFFICULTY          # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
      - CS2_BOT_QUOTA               # (Number of bots)
      - CS2_BOT_QUOTA_MODE          # (fill, competitive)
      # TV
      - TV_AUTORECORD=0             # Automatically records all games as CSTV demos: 0=off, 1=on.
      - TV_ENABLE=0                 # Activates CSTV on server: 0=off, 1=on.
      - TV_PORT=27020               # Host SourceTV port
      - TV_PW=tvpass                # CSTV password for clients
      - TV_RELAY_PW=relaypass       # CSTV password for relay proxies
      - TV_MAXRATE=0                # World snapshots to broadcast per second. Affects camera tickrate.
      - TV_DELAY=0                  # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
      # 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)
    volumes:
      - /home/zahti/cs2data-2:/home/steam/cs2-dedicated  # Persistent data volume mount point inside container
    ports:
      - "27115:27015/tcp"           # TCP
      - "27115:27015/udp"           # UDP
      - "27120:27020/udp"           # UDP
    stdin_open: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
    tty: true # Add local console for docker attach, docker attach --sig-proxy=false cs2-dedicated
zahti commented 7 months ago

Okay now the extra weird part. Both servers actually do look like they are running. Which makes sense since I am not seeing any issues in the logs. Are the ports conflicting somehow? image

I am able to connect to the 2 servers with manual console commands: connect 192.168.68.65:27015 image

connect 192.168.68.65:27115 image

joedwards32 commented 7 months ago

This is expected. What you are seeing in the server logs is the inside port binding. Remember there is this mapping going on between the outside host port and the inside container port

zahti commented 7 months ago

Is there a way to get them both to show up on the LAN tab in the server browser?

joedwards32 commented 7 months ago

I'm not sure how the LAN discovery works in CS2.

I think you will find that you can connect to both servers from the client if you issue the connect command from the CS2 developer console.

connect $ip:$port; password $password

For example

connect 10.0.0.30:27015; password changeme

zahti commented 7 months ago

I'm not sure how the LAN discovery works in CS2.

I think you will find that you can connect to both servers from the client if you issue the connect command from the CS2 developer console.

connect $ip:$port; password $password

For example

connect 10.0.0.30:27015; password changeme

Exactly! This is how I connected yesterday - thanks for the info though. I will keep playing around with the LAN discovery.

Note: If I have Online accesiblity enabled, I can actually see both servers independently in the Online tab of the server browser. However, the LAN tab only shows the first one (27015). Quite strange, but just wanted to mention it.

Also, I am noticing backwards functionality of the CS2_LAN variable to what I would expect. I'll double check this later with some examples and post a new issue for that if it turns out to be correct.

yznts commented 6 months ago

@joedwards32 just curious, there is no way to re-use downloaded game client between instances? So, each game instance must have own 40gb client in its own volume?

joedwards32 commented 6 months ago

They could possibly share a volume, but I haven't ever tested that.

Something like overlayfs could potentially be used to layer a writeable layer per container on top of a base layer containing a snapshot of the game.

subnetz commented 6 months ago

Is there a way to get them both to show up on the LAN tab in the server browser?

Hi, I haven't tested it myself, but back in Counter-Strike: Source, only a few ports next to 27015 get scanned automatically.

On the cs2-2 port mapping, try:

  cs2-server-2:
...
    ports:
      - "27016:27015/tcp"           # TCP - NOTE: Host side of the port mapping has changed to avoid port collisions
      - "27016:27015/udp"           # UDP - NOTE: Host side of the port mapping has changed to avoid port collisions
      - "27021:27020/udp"           # UDP - NOTE: Host side of the port mapping has changed to avoid port collisions
CM2Walki commented 6 months ago

Is there a way to get them both to show up on the LAN tab in the server browser?

Set the CS2_PORT per server instance, that's what the game server advertises to the steam master server. Right now it treats both of your instances as the same server (ip + game port are equal). Source: ISteamGameServer

cs2-server-1:
    environment:
      CS2_PORT: 27015
      TV_PORT: 27020
[...]
    ports:
      - "27015:27015/tcp"
      - "27015:27015/udp"
      - "27020:27020/udp" 
[...]
cs2-server-2:
    environment:
      CS2_PORT: 27016
      TV_PORT: 27021
[...]
    ports:
      - "27016:27016/tcp"
      - "27016:27016/udp"
      - "27021:27021/udp"