<p>I have a dockerfile with a custom SQL server 2019 installation running a bashscript, which in turn calls another bash script:</p>
<pre><code>FROM mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04 
ARG BuildConfiguration=Debug

USER root
# Install Unzip
RUN apt-get update \
    &amp;&amp; apt-get install unzip -y

# Install SQLPackage for Linux and make it executable
RUN wget -progress=bar:force -q -O sqlpackage.zip https://go.microsoft.com/fwlink/?linkid=2143497 \
    &amp;&amp; unzip -qq sqlpackage.zip -d /opt/sqlpackage \
    &amp;&amp; chmod +x /opt/sqlpackage/sqlpackage

USER mssql

# Create a config directory
RUN mkdir -p /usr/config
WORKDIR /usr/config

# Copy required source files
COPY entrypoint.sh /usr/config
COPY configure-db.sh /usr/config
COPY setup.sql /usr/config
COPY PrepareServer.sql /usr/config
COPY tSQLt.class.sql /usr/config
# Copy the dacpac, that we will be deploying. Make sure the project has built before you run the dockerfile!
COPY ./bin/${BuildConfiguration}/Database.dacpac /usr/config

ENTRYPOINT [&quot;/bin/bash&quot;, &quot;./entrypoint.sh&quot;]

CMD [&quot;tail -f /dev/null&quot;]

HEALTHCHECK --interval=15s CMD /opt/mssql-tools/bin/sqlcmd -U sa -P $MSSQL_SA_PASSWORD -Q &quot;select 1&quot; &amp;&amp; grep -q &quot;MSSQL CONFIG COMPLETE&quot; ./config.log
</code></pre>
<p>entrypoint.sh:</p>
<pre><code>#!/bin/bash

/opt/mssql/bin/sqlservr &amp;

/bin/bash /usr/config/configure-db.sh

eval $1
</code></pre>
<p>configure-db.sh:</p>
<pre><code>#!/bin/bash
# wait for MSSQL server to start
export STATUS=1
i=0

while [[ $STATUS -ne 0 ]] &amp;&amp; [[ $i -lt 30 ]]; do
    i=$i+1
    /opt/mssql-tools/bin/sqlcmd -t 1 -U sa -P $MSSQL_SA_PASSWORD -Q &quot;select 1&quot; &gt;&gt; /dev/null
    STATUS=$?
done

if [ $STATUS -ne 0 ]; then 
    echo &quot;Error: MSSQL SERVER took more than thirty seconds to start up.&quot;
    exit 1
fi

echo &quot;======= MSSQL SERVER STARTED ========&quot;
# Run the setup script to create the DB and the schema in the DB
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -d master -i setup.sql
#install the tSQLt CLR for testing
echo &quot;======= PREPARING FOR tSQLt ========&quot;
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -d master -i PrepareServer.sql
echo &quot;======= PREPARATION FOR tSQLt FINISHED ========&quot;
echo &quot;======= INSTALLING tSQLt ========&quot;
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -d master -i tSQLt.class.sql
echo &quot;======= INSTALLING tSQLt FINISHED========&quot;

echo &quot;======= Starting Deployment of Dacpac ========&quot;
/opt/sqlpackage/sqlpackage /a:Publish /tsn:. /tdn:${MSSQL_DB} /tu:sa /tp:$MSSQL_SA_PASSWORD /sf:/usr/config/Database.dacpac

echo &quot;======= Finished Deployment of Dacpac ========&quot;
echo &quot;======= MSSQL CONFIG COMPLETE =======&quot;
</code></pre>
<p>This is then deployed to Kuberenetes, but upon startup I see the following lines in the log:</p>
<pre><code>./entrypoint.sh: line 2: $'\r': command not found
./entrypoint.sh: line 3: $'\r': command not found
./entrypoint.sh: line 4: $'\r': command not found
: No such file or directoryigure-db.sh
./entrypoint.sh: line 6: $'\r': command not found
</code></pre>
<p>I have searched for the carriage return in Notepad++ and VSC, but could not find any. Notepad, as well as VSC display, that the EOL is set to Unix (LF)</p>
<p>I have tried to manually run the file configure-db.sh with bash inside the pod and receive the following output:</p>
<pre><code>mssql@sql-dev:/usr/config$ /bin/bash configure-db.sh 
configure-db.sh: line 5: $'\r': command not found
configure-db.sh: line 33: syntax error: unexpected end of file
</code></pre>
<p>Weirdly enough, running this with docker-compose works flawlessly. Is there something that I am doing wrong here?</p>
<p><strong>Update</strong>
Just to make sure, I did not overlook anything by accident I went ahead, and opened up the solution folder on WSL / Ubuntu and created an entrypoint2.sh with <code>sudo chown +x ./entrypoint2.sh</code> and referenced this in the dockerfile. I made sure, that the line ending were indeed LF / <code>\n</code> and <em>not</em> CR-LF, then checked the file in and deployed it. In addition I run the file through <code>dos2unix</code> again.</p>
<p>The outcome is identical. It works using docker-compose, but throws an error using Kubernetes:</p>
<pre><code>./entrypoint2.sh: line 2: $'\r': command not found
./entrypoint2.sh: line 4: $'\r': command not found
./entrypoint2.sh: line 5: $'\r': command not found
: No such file or directoryusr/config/configure-db.sh
./entrypoint2.sh: line 7: $'\r': command not found
</code></pre>

Marco
<p>The error isn't that bash isn't found, it's that <code>\r</code> isn't found. This indicates you've saved your script with Windows linefeeds and tried to run that script on a Linux platform. From your editor, save the script with Linux linefeeds (LF, not CR-LF). Or you can use a tool like dos2unix to strip the carriage returns from the script.</p>
