0
  1. Prepared Dockerfile which copied sh script

run.sh on the Centos 7 Linux.

  1. Checked this script

run.sh with vi. does not have any ^M

  1. docker-compose up --build and docker exec -it bash

inside the docker container, I have the script

run.sh with ^M additional symbols...

How to fix this .....king issue?

scala
  • 425
  • 1
  • 4
  • 12
  • 1
    Possible duplicate of [Remove carriage return in Unix](https://stackoverflow.com/questions/800030/remove-carriage-return-in-unix) – SiHa May 31 '18 at 18:36

1 Answers1

1

When I had this problem, it was because I had written the script on a Windows machine and then ported it to Linux. Windows line endings are different than Linux in that they have an extra character. The easiest way to fix this problem is to use the dos2unix utility.

dos2unix run.sh

If you don't have that installed, you can do sudo yum install dos2unix.

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53