I've written a Dockerfile with the intent of hosting a game server in a Docker container, but the shell script ("run.sh") that is COPY'd into the container doesn't see the ELF executable it is supposed to run.
I've configured my Dockerfile such that it uses the latest version of the ubuntu package, downloads and extracts the game server's files to a new folder, and then deletes the .zip archive. It successfully builds, but when I attempt to run it with a simple shell script consisting of three lines:
run.sh:
#!/usr/bin/env bash
pwd
ls
exec ./TerrariaServer.bin.x86 -steam -config ./config.txt
it always presents the following error:./run.sh: line 4: /ServerFiles/TerrariaServer.bin.x86: No such file or directory
pwd and ls confirm that TerrariaServer.bin.x86 is present in the /ServerFiles/ directory:
/ServerFiles
FNA.dll
FNA.dll.config
Mono.Posix.dll
Mono.Security.dll
System.Configuration.dll
System.Core.dll
System.Data.dll
System.Drawing.dll
System.Numerics.dll
System.Runtime.Serialization.dll
System.Security.dll
System.Windows.Forms.dll
System.Windows.Forms.dll.config
System.Xml.Linq.dll
System.Xml.dll
System.dll
Terraria.png
TerrariaServer
--> TerrariaServer.bin.x86 <--
TerrariaServer.bin.x86_64
TerrariaServer.exe
WindowsBase.dll
changelog.txt
config.txt
lib
lib64
monoconfig
monomachineconfig
mscorlib.dll
open-folder
run.sh
Other answers I've seen on StackOverflow have pointed to permissions conflicts (I've applied chmod 777 liberally for testing purposes) and Windows line endings (the Dockerfile and run.sh were both created and edited through nano via PuTTY), but no changes I make seem to affect the outcome.
Dockerfile:
FROM ubuntu:latest
# Get wget package
RUN apt-get update \
&& apt-get install -y wget \
&& apt-get install -y unzip \
&& rm -rf /var/lib/apt/lists/*
#RUN apt-get install dos2unix
# Download and extract Terraria server files
RUN pwd \
&& mkdir Downloads
RUN cd Downloads \
&& wget -O "/Downloads/TServer.zip"
http://terraria.org/server/terraria-server-1353.zip \
&& ls
RUN unzip "/Downloads/TServer.zip" -d "/Downloads/TServer/"
# Extract the linux folder and delete old files/folders
RUN cp -ra "/Downloads/TServer/1353/Linux/" "/ServerFiles/" \
&& rm -rf "/Downloads/TServer.zip" \
&& rm -rf "/Downloads/TServer/"
COPY run.sh /ServerFiles/run.sh
RUN chmod 777 /ServerFiles/run.sh
# Set the working directory
WORKDIR "/ServerFiles/"
RUN ls
RUN chmod 777 .
RUN chmod 777 TerrariaServer.bin.x86
RUN adduser --disabled-password --gecos '' tserveruser \
&& adduser tserveruser sudo
RUN chown -R tserveruser:tserveruser /ServerFiles
RUN chown tserveruser:tserveruser /ServerFiles/TerrariaServer
USER tserveruser
# Create the default config.txt
RUN printf "maxplayers=8\nport=7777\npassword=testpass\nworldpath=~/ServerFiles/Worlds/\ndifficulty=0\nautocreate=2\nworldname=World" \
> config.txt
ENTRYPOINT ["./run.sh"]
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)