steamcmd / docker

Docker image containing SteamCMD
https://hub.docker.com/r/steamcmd/steamcmd
MIT License
154 stars 21 forks source link

[BUG] Alpine image send error 42 at update #13

Closed shiipou closed 4 years ago

shiipou commented 4 years ago

When I use the steamcmd +quit command, I got the error 42

WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/root/Steam/logs/stderr.txt'
Could not find steamerrorreporter binary. Any minidumps will be uploaded in-process[  0%] Checking for available updates...
[----] Verifying installation...
[  0%] Downloading update...
[  0%] Checking for available updates...
[----] Download complete.
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching Steamcmd...
The command '/bin/sh -c steamcmd +quit' returned a non-zero code: 42

My Dockerfile was just :

FROM steamcmd/steamcmd:alpine

WORKDIR /steam

RUN steamcmd +quit

But if I remove the RUN steamcmd +quit and use the bash command after build : docker run -it --rm --entrypoint /bin/sh local-image then steamcmd +quit That work.

shiipou commented 4 years ago

I havn't that issue on the ubuntu image.

jonakoudijs commented 4 years ago

For some reason this is indeed the case with the alpine and busybox images. Perhaps the problem lies in using the builder method.

The moment steamcmd updates/rebuilds itself, it finishes with an exit code of 42. The second time steamcmd is run (and is already updated) it finishes with an exit code of 0. For example with Alpine:

/ # steamcmd +quit
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/root/Steam/logs/stderr.txt'
Could not find steamerrorreporter binary. Any minidumps will be uploaded in-process[  0%] Checking for available updates...
[----] Verifying installation...
[  0%] Downloading update...
[  0%] Checking for available updates...
[----] Download complete.
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching Steamcmd...
CWorkThreadPool::~CWorkThreadPool: work processing queue not empty: 3 items discarded.
/ # echo $?
42
/ # steamcmd +quit
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/root/Steam/logs/stderr.txt'
Could not find steamerrorreporter binary. Any minidumps will be uploaded in-process[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...Failed to init SDL priority manager: SDL not found
Failed to set thread priority: per-thread setup failed
Failed to set thread priority: per-thread setup failed
OK.
/ # echo $?
0

It's not pretty but that's why the Alpine Dockerfile pipes to true to avoid the build failing.

I will play around with it some more today. In the meantime you could add the pipe to true to your Dockerfile as well. Like this:

FROM steamcmd/steamcmd:alpine

WORKDIR /steam

RUN steamcmd +quit | true

RUN steamcmd +quit
jonakoudijs commented 4 years ago

I am not a big fan of wrapper scripts in general, so originally left them out in the alpine and busybox images by not using the steamcmd.sh script but directly executing thesteamcmd binary.

Taking a closer look from the steamcmd.sh script shows that the exit code of 42 is by design:

MAGIC_RESTART_EXITCODE=42

if [ "$DEBUGGER" == "gdb" ] || [ "$DEBUGGER" == "cgdb" ]; then
  ARGSFILE=$(mktemp $USER.steam.gdb.XXXX)

  # Set the LD_PRELOAD varname in the debugger, and unset the global version.
  if [ "$LD_PRELOAD" ]; then
    echo set env LD_PRELOAD=$LD_PRELOAD >> "$ARGSFILE"
    echo show env LD_PRELOAD >> "$ARGSFILE"
    unset LD_PRELOAD
  fi

  $DEBUGGER -x "$ARGSFILE" "$STEAMEXE" "$@"
  rm "$ARGSFILE"
else
  $DEBUGGER "$STEAMEXE" "$@"
fi

STATUS=$?

if [ $STATUS -eq $MAGIC_RESTART_EXITCODE ]; then
    exec "$0" "$@"
fi
jonakoudijs commented 4 years ago

@shiipou I reworked the Alpine build and the updated image has been pushed. I tested it with your example Dockerfile and it seems to work as expected now:

$ cat Dockerfile
FROM steamcmd/steamcmd:alpine

WORKDIR /steam

RUN steamcmd +quit
$ docker build -t steamcmd-shiipou .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM steamcmd/steamcmd:alpine
 ---> 07913c1d6ffa
Step 2/3 : WORKDIR /steam
 ---> Running in 77093d01d76b
Removing intermediate container 77093d01d76b
 ---> 748e43e9d4b6
Step 3/3 : RUN steamcmd +quit
 ---> Running in 4f4f065999c8
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/root/.steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
[  0%] Downloading update...
[  0%] Checking for available updates...
[----] Download complete.
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching Steamcmd...
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/root/.steam/logs/stderr.txt'
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...Failed to init SDL priority manager: SDL not found
Failed to set thread priority: per-thread setup failed
Failed to set thread priority: per-thread setup failed
OK.
Removing intermediate container 4f4f065999c8
 ---> 7c51a00eddd3
Successfully built 7c51a00eddd3
Successfully tagged steamcmd-shiipou:latest

Don't forget to pull the latest version of the alpine tag when you test it locally:

docker pull steamcmd/steamcmd:alpine

Let me know if it works for you :)

shiipou commented 4 years ago

Ok thanks, That work like a charm.

jonakoudijs commented 4 years ago

Great! Thanks for letting me know