0

I'm trying to set up a simple shell script that will do something along the following lines. Let's call it docker_maker.sh:

do stuff
docker build -t my-registry.com/my_image:latest .
docker push my-registry.com/my_image:latest
do more stuff

But when I call the script:

cd /where/my/dockerfile/is
sh docker_maker.sh

I get the following error:

unable to prepare context: path ".\r" not found

It seems that what is happening is that the docker build command is including the .\r linebreak characters as part of the build call. Is there a way that I could avoid this from happening?

Karl
  • 5,573
  • 8
  • 50
  • 73
  • 3
    This is strange. Can you pass the file via dos2unix and see if the issue persists? Looks like `docker build ... .` picks up a unreadable character `\r` somewhere. Or can you try placing the dot inside a `"` and a space after it, like `...:latest "." `? – KamilCuk Nov 14 '18 at 08:28
  • Yep, that was the problem. The file was created in Windows and deployed to a Linux instance. https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings (of which, now that I know the answer, my question is obviously a duplicate) explains it pretty well. Thanks – Karl Nov 14 '18 at 09:10

0 Answers0