Error Shell script fails on Docker for windows

0 votes

I’m trying to run an image on Docker for Windows.

I have a Dockerfile like this:

FROM openjdk:8-jre-alpine
WORKDIR /myworkdir
COPY path/tomyproject/src/main/bin/start /myworkdir/start
...
EXPOSE 8080
CMD [ "sh", "/myworkdir/start" ]


#!/bin/sh
SCRIPT="$0"
# set the environment variables received from the command line
for i; do
case "$i" in
  *=*) echo $i ;
  key=${i%=*}
  value=${i#*=};
  export $key=$value
esac
done

 i can't run it and get the following error:

: not found myworkdir/start: line 4: /myworkdir/start: line 6: syntax error: unexpected word (expecting "do")
Oct 15, 2018 in Docker by Sophie may
• 10,620 points
2,965 views

1 answer to this question.

+1 vote
I got a similar error, just try to delete the character \r in the script start, for example:  sed -i 's/\r//g' start Then copy the script start to windows and rebuild the image.
answered Oct 15, 2018 by Tyrion anex
• 8,700 points

Related Questions In Docker

+1 vote
3 answers
0 votes
1 answer
0 votes
1 answer
+2 votes
1 answer
0 votes
2 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP