I started trying to set up my own hosting system out of the box. Most servers like Minecraft and some Discord bots are fine, but when I started working on CS2 servers, I can't seem to connect to the server properly. For Minecraft servers, bots, and generally all containers, I use the image file as needed. For CS2, I decided on the cm2network/cs2:latest image, but I also tried joedwards32/cs2, and creating my own Docker file + SteamCMD, but it always ended with the same error: it wouldn't connect me to the currently running server in the container. It usually ended with an error like problem detected locally (5003): Timed out attempting to connect NETWORK_DISCONNECT_CONNECT_REQUEST_TIMEDOUT. I even asked ChatGPT what the issue was, and all of its options didn't work. When I ran the SteamCMD server on my own computer, not in Docker, I could connect without a problem. I tried all kinds of connections in the console, via Docker's IP, via localhost, literally everything. I tried port forwarding, opening the network as network=host when creating the container, has anyone else had this problem and managed to fix it somehow? I have Linux containers and I'm using Windows 11. Maybe that's the culprit, or maybe I should try a Linux VM? I'm asking for help because I've been struggling with this for almost a week now and I can't find a solution. Below is what the script for creating my container looks like
container = docker_client.containers.run(
image="cm2network/cs2:latest",
name=container_name,
detach=True,
tty=True,
stdin_open=True,
ports={f"{port}/udp": port, f"{port+1}/tcp": port+1},
volumes={server_path: {"bind": "/home/steam/cs2-dedicated", "mode": "rw"}},
environment={
"SRCDS_TOKEN": "A",
"SRCDS_PORT": str(port),
"SRCDS_TV_PORT": str(port + 10),
"SRCDS_MAXPLAYERS": str(slots),
"SRCDS_STARTMAP": "de_inferno",
"SRCDS_REGION": "3",
"SRCDS_LAN": "0",
"SRCDS_FPSMAX": "300",
"UPDATE_ON_START": "1",
"DB_HOST": db_info["db_host"],
"DB_NAME": db_info["db_name"],
"DB_USER": db_info["db_user"],
"DB_PASS": db_info["db_pass"],
},
mem_limit=f"{mem_limit_mb}m",
nano_cpus=int(cpus_per_server * 1e9),
restart_policy={"Name": "no"}
)