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
• 9,050 points
53 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
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,280 points

Related Questions In Docker

+1 vote
3 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.