0

I'm playing with Docker lately and I decided to start a little fun project so I have this Dockerfile :

# Base Image FROM debian:buster # Making steam directory RUN mkdir /home/cs &&\ mkdir /home/Resources &&\ mkdir /home/Resources/steamcmd &&\ mkdir /home/Resources/rehlds &&\ mkdir /home/Resources/metamod &&\ mkdir /home/Resources/amxmodx &&\ mkdir /home/Resources/reunion &&\ mkdir /home/Resources/rechecker &&\ mkdir /home/Resources/reaimdetector &&\ mkdir /home/Resources/cstrikefix &&\ mkdir /home/Resources/regamedll &&\ mkdir /home/Resources/reapi &&\ mkdir /root/.steam &&\ mkdir /root/.steam/sdk32 &&\ # Installing required packages dpkg --add-architecture i386 &&\ apt-get update -y &&\ apt-get install -y libsdl2-2.0-0 libsdl2-2.0-0:i386 lib32gcc1 curl tmux screen xz-utils unzip unrar-free nano &&\ # Installing the server cd /home/Resources/steamcmd &&\ curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - &&\ until ./steamcmd.sh +login anonymous +force_install_dir /home/cs +app_update 90 -beta beta validate +quit; do sleep 1; done &&\ # Fix steamclient.so issue cp /home/cs/steamclient.so /root/.steam/sdk32/ &&\ # reHLDS patch cd /home/Resources/rehlds &&\ curl -sqL "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/rehlds/rehlds/3.7.0.693-dev/rehlds-3.7.0.693-dev.zip" >> rehlds-3.7.0.693-dev.zip &&\ unzip rehlds-3.7.0.693-dev.zip &&\ cp -r bin/linux32/* /home/cs/ &&\ # Metamod cd /home/Resources/metamod &&\ curl -sqL "http://teamcity.rehlds.org/guestAuth/downloadArtifacts.html?buildTypeId=Metamod_Publish&buildId=lastSuccessful" >> Metamod_publish_1.3.0.128_artifacts.zip &&\ unzip -q Metamod_publish_1.3.0.128_artifacts.zip &&\ unzip -q metamod_1.3.0.128.zip &&\ cp -r addons /home/cs/cstrike &&\ sed -i 's+gamedll_linux "dlls/cs.so"+gamedll_linux "addons/metamod/metamod_i386.so"+g' /home/cs/cstrike/liblist.gam &&\ # AmxModX cd /home/Resources/amxmodx &&\ curl -sqL "https://www.amxmodx.org/release/amxmodx-1.8.2-base-linux.tar.gz" | tar zxvf - &&\ curl -sqL "https://www.amxmodx.org/release/amxmodx-1.8.2-cstrike-linux.tar.gz" | tar zxvf - &&\ cp -r addons /home/cs/cstrike/ &&\ echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> /home/cs/cstrike/addons/metamod/plugins.ini &&\ # Reunion cd /home/Resources/reunion &&\ curl -sqL "http://repository.btstelecom.ro/resources/reunion_0.1.92.zip" >> reunion_0.1.92.zip &&\ unzip reunion_0.1.92.zip &&\ mkdir /home/cs/cstrike/addons/reunion &&\ mkdir /home/cs/cstrike/addons/reunion/dlls &&\ cp bin/Linux/reunion_mm_i386.so /home/cs/cstrike/addons/reunion/dlls/ &&\ cp reunion.cfg /home/cs/cstrike/ &&\ echo "linux addons/reunion/dlls/reunion_mm_i386.so" >> /home/cs/cstrike/addons/metamod/plugins.ini &&\ # ReChecker cd /home/Resources/rechecker &&\ curl -sqL "https://amxx-bg.info/download/file.php?id=1444&sid=1811ca41ee4e4a17ea7110eecd7954a6" >> rechecker_2_5.zip &&\ unzip -q rechecker_2_5.zip &&\ mkdir /home/cs/cstrike/addons/rechecker &&\ mkdir /home/cs/cstrike/addons/rechecker/dlls &&\ cp bin/addons/rechecker/rechecker_mm_i386.so /home/cs/cstrike/addons/rechecker/dlls/ &&\ cp bin/addons/rechecker/resources.ini /home/cs/cstrike/addons/rechecker/dlls/ &&\ echo "linux addons/rechecker/dlls/rechecker_mm_i386.so" >> /home/cs/cstrike/addons/metamod/plugins.ini &&\ # cstrike fix cd /home/Resources/cstrikefix &&\ mkdir /home/cs/cstrike/addons/cstrike &&\ mkdir /home/cs/cstrike/addons/cstrike/dlls &&\ curl --header "Host: c-s.net.ua" --header "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36" --header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" --header "Accept-Language: ro-RO,ro;q=0.9,en;q=0.8" --header "Referer: https://c-s.net.ua/forum/topic81470.html" --header "Cookie: _ga=GA1.3.1603347949.1602960053; __gads=ID=f426b07af5c143a1-22526794ffb800af:T=1603190043:RT=1603190043:S=ALNI_MaFPky-pOiwPIbZanyNiU0Ksdqm0Q; session_id=9fb1924d44b7d5b77af02e9680400c4f; topicsread=a%3A4%3A%7Bi%3A17628%3Bi%3A1603190043%3Bi%3A84615%3Bi%3A1604348502%3Bi%3A81470%3Bi%3A1604348492%3Bi%3A74614%3Bi%3A1603821602%3B%7D; _gid=GA1.3.999712779.1604595471" --header "Connection: keep-alive" "https://c-s.net.ua/forum/ipb.html?act=attach&type=post&id=40051" -L -o 'cstrike_amxx_1_8_2_fix.zip' &&\ unzip -q cstrike_amxx_1_8_2_fix.zip &&\ cd cstrike_amxx_1_8_2_fix &&\ cp cstrike_amxx_i386.so /home/cs/cstrike/addons/cstrike/dlls &&\ echo "linux addons/cstrike/dlls/cstrike_amxx_i386.so" >> /home/cs/cstrike/addons/metamod/plugins.ini &&\ # ReGameDLL cd /home/Resources/regamedll &&\ mkdir /home/cs/cstrike/addons/regamedll &&\ curl --header "Host: c-s.net.ua" --header "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36" --header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" --header "Accept-Language: ro-RO,ro;q=0.9,en;q=0.8" --header "Referer: https://c-s.net.ua/forum/topic81470.html" --header "Cookie: _ga=GA1.3.1603347949.1602960053; __gads=ID=f426b07af5c143a1-22526794ffb800af:T=1603190043:RT=1603190043:S=ALNI_MaFPky-pOiwPIbZanyNiU0Ksdqm0Q; _gid=GA1.3.999712779.1604595471; session_id=1176d37d74d1a5cf21577ccba8e1f55d; topicsread=a%3A4%3A%7Bi%3A17628%3Bi%3A1603190043%3Bi%3A84615%3Bi%3A1604596752%3Bi%3A81470%3Bi%3A1604348492%3Bi%3A74614%3Bi%3A1603821602%3B%7D" --header "Connection: keep-alive" "https://c-s.net.ua/forum/ipb.html?act=attach&type=post&id=45156" -L -o 'ReGameDLL_CS_publish_5.3.0.217_artifacts.zip' &&\ unzip -q ReGameDLL_CS_publish_5.3.0.217_artifacts.zip &&\ unzip -q regamedll-dist-5.3.0.217-dev.zip &&\ cp bin/bugfixed/cs.so /home/cs/cstrike/dlls &&\ cp game.cfg /home/cs/cstrike &&\ # ReAimDetector cd /home/Resources/reaimdetector &&\ curl --header "Host: c-s.net.ua" --header "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36" --header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" --header "Accept-Language: ro-RO,ro;q=0.9,en;q=0.8" --header "Referer: https://c-s.net.ua/forum/topic84615.html" --header "Cookie: _ga=GA1.3.1603347949.1602960053;__gads=ID=f426b07af5c143a1-22526794ffb800af:T=1603190043:RT=1603190043:S=ALNI_MaFPky-pOiwPIbZanyNiU0Ksdqm0Q; session_id=b83b284a0cf31d151d82a2dd7600f65d; topicsread=a%3A4%3A%7Bi%3A17628%3Bi%3A1603190043%3Bi%3A84615%3Bi%3A1603916003%3Bi%3A81470%3Bi%3A1603477078%3Bi%3A74614%3Bi%3A1603821602%3B%7D; _gid=GA1.3.252331836.1603916004; _gat=1" --header "Connection: keep-alive" "https://c-s.net.ua/forum/ipb.html?act=attach&type=post&id=47508" -L -o 'reaimdetector_0.2.2.rar' &&\ unrar x reaimdetector_0.2.2.rar &&\ cp -r linux/addons /home/cs/cstrike/ &&\ echo "reaimdetector" >> /home/cs/cstrike/addons/amxmodx/configs/modules.ini &&\ cd /home/cs/cstrike/addons/amxmodx/scripting &&\ ./amxxpc reaimdetector.sma &&\ cp reaimdetector.amxx /home/cs/cstrike/addons/amxmodx/plugins/ &&\ echo "reaimdetector.amxx" >> /home/cs/cstrike/addons/amxmodx/configs/plugins.ini &&\ # Cleaning rm -rf /home/Resources &&\ # Run server cd /home/cs/ &&\ screen -A -m -d -S cs /home/cs/hlds_run -game cstrike +maxplayers 25 +map de_dust2 -autoupdate -pingboost 3" >> /home/cs/start.sh 

The last screen command doesn't run when I start the container but when I enter in the container and run the exact same command it does run. The dockerfile builds an Counter-Strike 1.6 Server with reHLDS.

Edit: After I've tried ti7 method when I run the container it gives me this error :

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"start.sh\": executable file not found in $PATH": unknown. 

This is the code I've tried :

echo "#!/bin/sh" >> /home/cs/start.sh &&\ echo "# start.sh" &&\ echo "screen -A -m -d -S cs /home/cs/hlds_run -game cstrike +maxplayers 25 +map de_dust2 -autoupdate -pingboost 3" >> /home/cs/start.sh &&\ chmod +x /home/cs/start.sh &&\ /home/cs/start.sh WORKDIR /home/cs/ ENTRYPOINT ["/home/cs/start.sh"] 

This is the command I run the image with :

sudo docker run -itd -p 27015:27015/udp --name=cs cstrike /bin/bash 
0

1 Answer 1

3

The screen is created before the container is finished

Directly set commands which should start with the container when it begins into the ENTRYPOINT or a script which it calls

#!/bin/bash # start.sh screen screen_command # exec the final command replacing this script with the new process # this makes the new process the forefront in Docker, keeping the container # running until it exits and allowing signals to be passed (such as ^C) exec sleep infinity 
... RUN generate_script.sh WORKDIR /home/cs/ ENTRYPOINT ["/home/cs/start.sh"] 

With an ENTRYPOINT, you don't need to specify any shell when running the container
Arguments passed after the name will be sent to the container and can be interpreted by the script more

docker run --detach --init --name foo-name container 
Sign up to request clarification or add additional context in comments.

12 Comments

CMD is probably better.
I've had mixed experience and I recall ENTRYPOINT is more convenient to pass arguments to (though that may not or may no longer be the case)
@Zeth ah, you should call it with a full or relative path - I've updated my answer too
does it work? the layers should be cached
@ti7 now the container exists after 1 sec
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.