0

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.

MattArgo
  • 21
  • 5

0 Answers0