mvnw file throwing error in windows while building docker image - spring

I have a spring-boot project which was created on mac and pushed to github, I am cloning it on my windows 10 laptop, and trying to build docker image by referring to Multi-Stage Build https://spring.io/guides/topicals/spring-boot-docker/
here while running the Dockerfile I am getting following error:
---> Running in 4ae632bc1c4b
/bin/sh: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory
I know that dos2unix.exe mvnw will fix the issue, but just wanted to know why this is happening, I am not editing the mvnw file on my windows and still it is having some windows line endings.

I fixed it by changing the encoding of the /mvnw file to UTF8 - LF. After this I was able to generate the image without problem.

Related

Issue when running docker build on Windows machine: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory [duplicate]

This question already has answers here:
./configure : /bin/sh^M : bad interpreter [duplicate]
(15 answers)
Bash - seamlessly run scripts with CRLF line endings
(5 answers)
Issue with line endings when developing on a Windows but running on a UNIX docker container
(3 answers)
Closed 11 days ago.
This post was edited and submitted for review 11 days ago and failed to reopen the post:
Original close reason(s) were not resolved
The Issue
When trying to run docker build on my Windows machine, I receive the following error:
------
> [build 6/9] RUN ./mvnw dependency:go-offline -B:
#10 0.300 /bin/sh: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory
------
executor failed running [/bin/sh -c ./mvnw dependency:go-offline -B]: exit code: 126
The Code
This is the relevant piece of my Dockerfile:
#### Stage 1: Build the application
FROM adoptopenjdk/openjdk8:ubi as build
# Set the current working directory inside the image
WORKDIR /app
# Copy maven executable to the image
COPY mvnw .
COPY .mvn .mvn
# Copy the pom.xml file
COPY pom.xml .
# Build all the dependencies in preparation to go offline.
# This is a separate step so the dependencies will be cached unless
# the pom.xml file has changed.
RUN ./mvnw dependency:go-offline -B
Context
This works on my Mac machine, but not my Windows machine (Windows 11). I realize this is a carriage return issue, though is there a way to let docker know with a flag that it should be running the commands using Windows syntax?
Conclusion
Tried running docker build -t <name> . expecting a successful build, but got an error involving carriage return mismatch.
This is distinct from similar questions in that there is no one file I'm trying to run which needs to be converted from Windows to Unix. Instead, within Docker mvnw is being run which internally has the problem.

docker env: bash\r: No such file or directory

While locally deploying an app in PyCharm on windows10, I have encountered several mistakes.
Make test command returned following mistake:
service "core" is not running container #1
make: *** [Makefile:60: test] Error 1
And indeed container status with the command make ps returned exited(127). When I have checked docker logs for the container in question, I've seen:
/usr/bin/env: ‘bash\r’: No such file or directory
In this thread, this mistake is connected to how windows processes line endings of files from different OS. The usual solution is:
git config --global core.autocrlf false
But after running the code and updating current git repo and restarting the containers, i still get the same mistake. What might be the issue here?
What did helped me
I assume that the problem was in the windows line endings in the Unix-based containers.
To solve it I found two very helpful instructions:
Configure your line separators in the PyCharm https://www.jetbrains.com/help/pycharm/configuring-line-endings-and-line-separators.html
To clarify that changes were really enabled, I have checked the files in the notepad++
https://notepad-plus-plus.org/downloads/v8.1.9.3/
Also it was helpful to check the original code because part of the problem was the incorrect spelling of some commands.
When I use Windows in Docker and run a bash script, I have a similar problem, which I solve by using LF instead of CRLDF as the line separator.
in vscode, we can change it here

Why is my docker build command failing

I have docker installed on my macbook pro OS Sierra 16G1212
I have a simple docker file in /mypath/Dockerfile
When I try the command:
docker build .
I get an error:
error checking context: 'can't stat '/Users/bdisha/Library/Caches/com.cisco.Jabber/com.apple.opencl''.
What am I doing wrong?
Thank you
The problem was resolved by me creating a "dockerfiles" directory and moving my Dockerfile in there.
After that, I could manage to build the image just fine.

docker in mac: ./start.sh: no such file or directory"

I am trying to run docker on my macbook with sierra... It is okay to build and run on my openshift but I have a problem on local. I think the problem is in this line:
COPY . /tmp/app
and the docker cant copy files (including start.sh) to path. can you help me please?

JSP, OSX 10.9.4 & ImageMagick - "/opt/local/bin/identify": error=2, No such file or directory

I am currently working on a large legacy JSP project - not that I know anything about JSP. I have tried to set up the app in IntelliJ and I have set numerous keys in my .MacOSX/environment.plist file however when I try to upload an image (ImageMagick is used) in my local environment in the application I get the following error in the debug terminal (the error is all on one line):
.ImageUploadException: command /opt/local/bin/identify -format %w;%h; - failed: java.util.concurrent.ExecutionException: java.io.IOException: Cannot run program "/opt/local/bin/identify": error=2, No such file or directory
to make the error easier to read
.ImageUploadException: command /opt/local/bin/identify -format %w;%h;
- failed: java.util.concurrent.ExecutionException: java.io.IOException:
Cannot run program "/opt/local/bin/identify": error=2, No such file or directory
After some research I create a launchd.conf file in the /etc folder and added the following line as advised on Stackoverflow and some other places:
setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I rebooted and I still get the same error? If I run echo $PATH in my terminal I get the following:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Does anyone know what I am doing wrong? I am using a MacBook Pro running OS X 10.9.4 and MacPorts is installed as when I run $ which port I get the following: /opt/local/bin/port
Thanks in advance
What I did was reinstall the X-Code tools and reinstalled ImageMagick after the amends above... it all seems to work now?

Resources