3

I am trying to complete the instructions here: https://docs.docker.com/compose/aspnet-mssql-compose/. I am at the last stage:

$ docker-compose up

I see this error:

DotNetCore$ sudo docker-compose up
Starting dotnetcore_db_1 ... done
Starting dotnetcore_web_1 ... done
Attaching to dotnetcore_db_1, dotnetcore_web_1
web_1  | ./entrypoint.sh: line 2: $'\r': command not found
: invalid optionpoint.sh: line 3: set: -
web_1  | set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
web_1  | ./entrypoint.sh: line 5: $'\r': command not found
web_1  | ./entrypoint.sh: line 15: syntax error: unexpected end of file
dotnetcore_web_1 exited with code 2

I have spent all day trying to fix this simple error. Here is the entrypoint.sh:

#!/bin/bash

set -e
run_cmd="dotnet run --server.urls http://*:80"

until dotnet ef database update; do
>&2 echo "SQL Server is starting up"
sleep 1
done

>&2 echo "SQL Server is up - executing command"
exec $run_cmd

So far I have tried:

1) Open file using Notepad ++  and select Edit/EOL Conversion.  Unix is greyed out.  This method is descrbed here: https://askubuntu.com/questions/966488/how-do-i-fix-r-command-not-found-errors-running-bash-scripts-in-wsl

2) sudo dos2unix {filename}.  This method is desecribed here: https://askubuntu.com/questions/966488/how-do-i-fix-r-command-not-found-errors-running-bash-scripts-in-wsl

How can I resolve this?

w0051977
  • 15,099
  • 32
  • 152
  • 329
  • Possible duplicate of [Are shell scripts sensitive to encoding and line endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – tripleee Jul 29 '18 at 16:00
  • Replace bashism `$'\r'` with more general `$(printf "\r")` that works in `sh`, too. – mviereck Jul 29 '18 at 16:35

2 Answers2

3

Your entrypoint script has windows linefeeds in it, they aren't valid on a Linux OS and are being parsed as commands to run. Correct that with your editor in the save menu, or use a utility like dos2unix to correct the files.

Once you have removed the linefeeds, you'll need to rebuild your image and then recreate a new container.

BMitch
  • 231,797
  • 42
  • 475
  • 450
1

You could also set:

git config --global core.autocrlf input

from: https://github.com/docker/toolbox/issues/126

reisner
  • 242
  • 3
  • 14