kaimallea / csgo

A containerized dedicated server for Counter-Strike: Global Offensive
The Unlicense
242 stars 58 forks source link

Server won't start #20

Closed fuzzy76 closed 4 years ago

fuzzy76 commented 4 years ago

Service-definition from my docker-compose.yml:

  csgo:
    env_file: ./data_env/csgo.env
    image: kmallea/csgo:latest
    ports:
      - target: 27015
        published: 27015
        protocol: tcp
        mode: host
      - target: 27015
        published: 27015
        protocol: udp
        mode: host
      - target: 27020
        published: 27020
        protocol: tcp
        mode: host
      - target: 27020
        published: 27020
        protocol: udp
        mode: host
    restart: unless-stopped
    volumes:
      - "csgo_data:/home/steam/csgo"

Log output:

csgo_1        | Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
csgo_1        | [  0%] Checking for available updates...
csgo_1        | [----] Verifying installation...
csgo_1        | Steam Console Client (c) Valve Corporation
csgo_1        | -- type 'quit' to exit --
csgo_1        | Loading Steam API...Failed to init SDL priority manager: SDL not found
csgo_1        | Failed to set thread priority: per-thread setup failed
csgo_1        | OK.
csgo_1        | Failed to set thread priority: per-thread setup failed
csgo_1        | 
csgo_1        | Connecting anonymously to Steam Public...Loaded client id: 18364441488310737475
csgo_1        | Listening for IPv4 broadcast on: 27036
csgo_1        | Logged in OK
csgo_1        | Waiting for user info...OK
csgo_1        | ERROR! Failed to install app '740' (Disk write failure)
csgo_1        | CWorkThreadPool::~CWorkThreadPool: work processing queue not empty: 2 items discarded.
csgo_1        | CWorkThreadPool::~CWorkThreadPool: work processing queue not empty: 3 items discarded.
csgo_1        | /home/steam/start.sh: line 33: /home/steam/csgo/csgo/cfg/autoexec.cfg: No such file or directory
csgo_1        | /home/steam/start.sh: line 44: /home/steam/csgo/csgo/cfg/server.cfg: No such file or directory
csgo_1        | Installing plugins...
csgo_1        | mkdir: cannot create directory ‘/home/steam/csgo/csgo’: Permission denied
csgo_1        | /bin/bash: /home/steam/csgo/srcds_run: No such file or directory
kaimallea commented 4 years ago

Looks like a problem with the volume since steam couldn’t write to disk. Do you also have a top level volumes key declaring the named volume? See https://docs.docker.com/compose/compose-file/#volume-configuration-reference

Also, does the example Docker compose file in this repo work for you?

fuzzy76 commented 4 years ago

I have defined the volume at top level, yes.

The example Docker compose file gives me the same error.

If I run a shell inside the container I notice that /home/steam looks like this:

drwxr-xr-x 1 steam steam 4.0K Mar 27 19:38 .
drwxr-xr-x 1 root  root  4.0K Mar 27 19:38 ..
-rw-r--r-- 1 steam steam  127 Mar 27 19:38 autoupdate_script.txt
-rw-r--r-- 1 steam steam  220 Mar 27 19:38 .bash_logout
-rw-r--r-- 1 steam steam 3.7K Mar 27 19:38 .bashrc
drwxr-xr-x 2 root  root  4.0K Mar 27 19:38 csgo
-rwxr-xr-x 1 steam steam 3.6K Mar 27 19:36 manage_plugins.sh
-rw-r--r-- 1 steam steam  807 Mar 27 19:38 .profile
-rw-r--r-- 1 steam steam  767 Mar 27 19:36 README.md
-rwxr-xr-x 1 steam steam 2.5K Mar 27 19:36 start.sh
drwxr-xr-x 3 steam steam 4.0K Mar 27 19:38 .steam
drwxr-xr-x 3 steam steam 4.0K Mar 27 19:38 steamcmd

So if steamcmd is run as the steam user, it's understandable why it can't write to /home/steam/csgo - it's owned by root and not world writable.

fuzzy76 commented 4 years ago

Starting a shell as root in the container and doing a chown -R steam /home/steam/csgo fixed it though. But there is probably some init script that doesn't work as intended.

kaimallea commented 4 years ago

Thanks for debugging! I'll take a look to see what may have caused this. I suspect a recent change that no longer creates the directory beforehand in the image.

The entire /home/steam directory has its owner:group perms recursively set to steam:steam as part of the build process, so wondering how it was set as root. 🤔

kaimallea commented 4 years ago

Okay, I tracked down the issue and fixed it in #23. I initially missed this bug because I was reusing a volume that already existed didn't have the perm issue. Time for me to add tests to the repo.

Thanks again for taking the time to report your issue and debug! 🙌

fuzzy76 commented 2 years ago

Did you add tests? I suspect #62 is of a similar nature :p